Fixed, thank you Audrey
Also, fixed - whether to call finish()
here or not was a tough call, but I think itās better not to.
so you can also remove the return
Yes, definitely Thanks Audrey
In Chapter 4, Section 2, Subsection Simplifying async sequences with AsyncStream, the first initializer in the list of initializers seems to have odd formatting due to Swifts unlabelled parameters:
init(_:bufferingPolicy:_:)
is rendered as init(:bufferingPolicy::): because the (Iām guessing here) _
is treated as a markdown indicator and not an unlabeled marker.
Either the first code block or the last code block in Chapter 4, Section 3, Subsection _ Stopping the timer and sending the message_ is incorrect:
If the first is incorrect, then it should be
guard countdown > 0 else {
timer.invalidate()
continuation.yield("š " + message)
- continuation.finish()
return
}
If the last code block is incorrect, the it should be
let counter = AsyncStream<String> { continuation in
var countdown = 3
Timer.scheduledTimer(
withTimeInterval: 1.0,
repeats: true
) { timer in
guard countdown > 0 else {
timer.invalidate()
continuation.yield(with: .success("š " + message))
+ continuation.finish()
return
}
continuation.yield("\(countdown) ...")
countdown -= 1
}
}
(Iām not sure which is correct but the final project says the finish
call is not needed)
Iām working on the " Simplifying async sequences with AsyncStream" in chapter 4.
Iām using Xcode 14.1 beta 2
for the typewrite example using AsyncStream
I get the following errors in a playgroundā¦
Main actor-isolated var 'index' can not be mutated from a non-isolated context
Main actor-isolated var 'phrase' can not be referenced from a non-isolated context
The code was cut-and-pasted right from the web site, so I didnāt introduce a type-o. Any ideas?
Chapter 5: Location sharing is not working. It is not giving error, it is not printing location in console, delegate methods are not getting called. Nothing is happening.
What Xcode version are you using? Since the book was published for Xcode 13 there were a round of changes to context detection.
This is interesting, Iād expect the code to either output some warnings in the output console or other output if it runs. Have you tried the completed project for this chapter and verify if that works for you?
Tried complete code and it doesnāt work either. Donāt see any warning in console except one case, where if we press location sharing button more than once, it shows ācontinuation leakā warning in console.
I am using Xcode 14.0.1 (14A400)
@dev_invideo I looked again into this today and it seems like CLLocationManager
got some update in iOS16 that makes it deadlock the way the example app initialized it.
I have a pending PR here that avoids the deadlock (not sure if thatās actually an iOS bug or not): ios16 updates by icanzilb Ā· Pull Request #26 Ā· raywenderlich/mcon-materials Ā· GitHub if you want, you can give it a try and see if it solves the issue you experience.
This topic was automatically closed after 3 hours. New replies are no longer allowed.