Code snippet for Async transitions should have the removal scale to 0.0 and not 1.0.
It will be updated for the next book version. You can fix by dropping the state variable in the preview and replace it with .constant(true)
as the parameter for showModal and it should work.
Iâll look at the code snippet.
Thanks!
I just started reading the book and found a very minor typo. On page 12, in this sentence:
âWeâve also set up an official forum for the book at https:// forums.kodeco.com/c/books/swiftui-by-tutorials.â
the text is correct, but the embedded link uses âhttpâ instead of âhttpsâ. As a result, Safari doesnât resolve it and results in a broken link. Copying the https text into the browser works, though.
Hi everyone!
In release Xcode 11 it seems much have changed:
Now Slider(constant: 0.3) seems to make static slider. (Until we make HStack like in âMaking Reusable Viewsâ)
But Iâm still on Mohave, maybe this is the problem.
Will early access be updated for release versions? Or you will update final version of the book?
Thanks
Hi! The final version will certainly be up to date for Xcode 11.
But Iâm not sure what you mean about Slider
.
Slider(value: .constant(0.3))
creates a Slider
with the thumb at 0.3, and you canât move it, even if you embed Slider
in an HStack
.
There is an error in the Chapter 7: State & Data Flow.
In the ChoicesViewâs body property you need to update the code from:
var body: some View {
VStack(spacing: 25) {
ForEach(0 ..< self.answers.count) { index in
Button(action: {
self.answer(self.answers[index])
}, label: {
Text(self.answers[index])
.font(.title)
})
Divider()
}
}
}
to:
var body: some View {
VStack(spacing: 25) {
ForEach(self.answers, id: \.self) { answer in
Group {
Button(action: {
self.answer(answer)
}, label: {
Text(answer)
.font(.title)
})
Divider()
}
}
}
}
In order to fix the bug you can see in the console too:
ForEach<Range, Int, TupleView<(Button, Divider)>> count (3) != its initial count (0). ForEach(_:content:)
should only be used for constant data. Instead conform data to Identifiable
or use ForEach(_:id:content:)
and provide an explicit id
!
Chapter 6 (page 214 in iBooks) Splitting Text note. I think the âlast two modifiersâ should be .font and .bold, not .lineLimit and .multilineTextAlignment.
In the code, #If DEBUG and #endif are no longer required for the preview blocks
Thank you very much - you are right, I listed the wrong modifiers.
The code provided for BullsEyePlus in Chapter 5 has an incorrect computed value for the alpha variable.
It should be the complement value.
private var alpha: Double {
1 - (abs(Double(game.targetValue) - currentValue) / 100.0)
}
In Chapter 5, the first image showing you when adding the targetâs Framework shows you correctly adding the Workspace/Game/Game from the list.
The image showing the added framework for the WatchKit extension as Games (note the s on the end of Game)
youâre right! weâll get rid of them all in the next update.
thanks! I thought Iâd caught them all
the projectâs alpha value is correct: when currentValue == targetValue
, alpha
is 0 â the idea is for the slider thumb to disappear when itâs in the correct location.
in the previous chapterâs challenge, alpha is 1.0 - Double(computeScore())/100.0
because computeScore
returns 100 - difference
.
Yes, sorry. I misread this. I, for some reason thought that it was the other way round, where the Alpha became 1 when you were on target. It makes the game a lot more difficult
There are two chapters with the number 6 in the title heading.
page 102 âChapter 6: Intro to controls: Text & Imageâ
Page 128 âChapter 6: State & Data Flowâ
However the table of contents has page 128 listed as chap 7.
More importantly here is an editorial suggestion: the State & Data flow chapter departs from the tutorial format. It is structured as a commentary upon the example Kuchi app rather than the point by point construction of the prior tutorial chapters.
In fact from some of the writing it almost feels like there was chapter deleted at the last minute where the example was constructed. Or alternatively in the rush to publish the construction segments did not get completed.
For example page 136 "âYouâve already decided that your WelcomeView and your RegisterView need to share some information. Initially, you identified the shared information to be the name of your userâ â actually the reader has not done anything yet in this chapter except read commentary and code.
I agree with the intro that the topic is very important. The tutorial approach of the other chapters has been working very well with my personal learning style. Can you consider a major expansion of this chapter in the next edition? Thanks !!! Will L-B
Not sure if this has been caught yetâŠ
In Chapter 7, when you add practice
to the initializer, it breaks the ChallengeView_Previews
.
I changed it to the following to get rid of the error:
#if DEBUG
struct ChallengeView_Previews: PreviewProvider {
static var previews: some View {
return ChallengeView(onComplete: {}, practice: PracticeStore())
}
}
#endif
Chapter 10, page 235
I think that the following code:
ScrollView {
VStack {
Text("\(fl.airline) \(fl.number)") Text("\(fl.flightStatus) at \(fl.currentTimeString)") Text("At gate \(fl.gate)")
} }
Should actually be:
ScrollView {
ForEach(flightData) { fl in
VStack {
Text("\(fl.airline) \(fl.number)")
Text("\(fl.flightStatus) at \(fl.currentTimeString)")
Text("At gate \(fl.gate)")
}
}
}
If the ScrollView
is left as-is, each flight information section is wrapped in a ScrollView
rather than wrapping all of them inside of one, large, ScrollView
Youâre correct. The text mentions the ForEach()
should be wrapped, but doesnât show it in the code sample. Weâll get it fixed in the next update.
I thought the same and was glad to have found your comment before submitting my own.