Errata for SwiftUI by Tutorials 1st Edition

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 :blush:

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 :slight_smile:

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

8 Likes

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

1 Like

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.

1 Like

I thought the same and was glad to have found your comment before submitting my own. :slight_smile:

2 Likes

Note, this is now “Chapter 14” page 420 (iBooks).

if showDetails {
FlightDetails(flight: flight)
.offset(x: showDetails ? 0 : -UIScreen.main.bounds.width)
}

becomes

FlightDetails(flight: flight)
.offset(x: showDetails ? 0 : -UIScreen.main.bounds.width)

I came here for this exact reason. Once I hit the State & Data Flow chapter, I got very confused because it was referencing a completed project and there was no tutorial. I too hope this all to important topic can be expanded to include tutorials.

Also came here to echo this sentiment. I hit Chapter 7 and immediately felt confused about how I should be following along. I’m concerned that anyone new to SwitUI might get lost completely here.

Hi All - enjoyed going through the book. Found a fair few errors / things that IMO should have been updated for the v1 release to maintain RW standard. Feels like this release was slightly rushed and amazed so many issues got passed the editors.

Page 20
SwiftUI surely follow the same path
SwiftUI will surely follow the same path

Page 25

#if DEBUG
struct ContentView_Previews : PreviewProvider {
  static var previews: some View {
    ContentView()
  }
} #endif 

struct ContentView_Previews : PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}

Page 27
Xcode 11 beta
Xcode 11

Page 27
Picture needs to be updated to not have #if DEBUG statement

Page 34
Scroll down to the DEBUG block - DEBUG is no longer needed

Page 39
Top Picture has #if DEBUG

Page 40 - Note - Xcode 11 is no longer beta

P 62
@Binding var is a reference to the data, so it doesn’t need initialization
@Binding var is a reference to the data, so it doesn’t need a default value

Part of me thinks this should say default value instead. It still needs to be initialised in the struct init

P77
Below the import SwiftUI statement, import UIKit
No need to import UIKit as SwiftUI imports it

p80
view.value = Float(self.value)
uiView.value = Float(self.value)

self.value.value = Double(sender.value)
self.value.wrappedValue = Double(sender.value)

P81
so value.value
so value.wrappedValue

P117 - p118
The same image is used twice. Should only be shown once.

P126
but you’ll go into scaling more in- depth in in the next chapter as well as in Chapter 16, “Expanding the UI”
There is no chapter 16 or a chapter called Expanding the UI

P127
The text for .border image
.border(Color.gray, width: 1, cornerRadius: size / 2)
.border(Color.gray, width: 1)

P137
This is a huge help to people who eyesight issues or visual impairments.
This is a huge help to people with eyesight issues or visual impairments.

You’ll learn more about fonts and accessibility in Chapter 16, “Expanding the UI”
There is no chapter 16 or a chapter called Expanding the UI

P142
If you need a fresh project to continue, locate the starter project for this chapter and open it up.
Locate the starter project for this chapter and open it up.

In chapter 6 - there is no registerView and so a user will need to use the starter project

P154
You’ll begin with your SceneDelegate .swift*
You’ll begin with your SceneDelegate .swift

P155
After changing the practiceStore PropertyWrapper in ChallengeView from an @EnvironmentObject to an @ObservedObject the init for ChallengeView in PractiveView and in ChallengeView_Previews needs to be updated. Probably worth mentioning to reader.

P161
This is a pattern that’s used frequently and often recommended Apple , .
This is a pattern that’s used frequently and often recommended by Apple

P164

VStack(content: {
    WelcomeMessageView()
})

VStack {
    WelcomeMessageView()
}

p166
@State var name: String = “”
@State private var name: String = “”

P189
Text("\(slider)")
Text("\(amount)")

P191
Refactoring and reusing views are two important aspects that should never be neglected nr forgotten
Refactoring and reusing views are two important aspects that should never be neglected or forgotten

P200
The differences between this and the the case of views with a single child that you’ve seen in the previous section are highlighted in bold text
The differences between this and the case of views with a single child that you’ve seen in the previous section are highlighted in bold text

P219
@State var showAnswers = false
@State private var showAnswers = false

P219
For this to work, you also need a custom initializer to pass in the challenge test and assign it to the property.
This initializer is provided by default from the ChallengeView struct

P220
self.showAnswers = !self.showAnswers
self.showAnswers.toggle()

P224
Why are FlightHistory and FlightInformation subclasses of NSObject ??

class FlightInformation: NSObject {}		
class FlightHistory: NSObject {}
		
final class FlightInformation { }
final class FlightHistory { }

P235

ScrollView {
  VStack {
    Text("\(fl.airline) \(fl.number)") 
    Text("\(fl.flightStatus) at \(fl.currentTimeString)") 
    Text("At gate \(fl.gate)")
  } 
}

ScrollView {
  ForEach(flightData) { flight in
    VStack {
      Text("\(flight.airline) \(flight.number)")
      Text("\(flight.flightStatus) at \(flight.currentTimeString)")
      Text("At gate \(flight.gate)")
    }
  }
}

P238
You now need to set the title for this view in the view stack.
You now need to set the title for this view in the view stack and delete the Text View at the top of the VStack.

P242

.navigationBarItems(trailing: 
  Toggle(isOn: $hideCancelled, label: { 
    Text("Hide Canceled")
  })
)

.navigationBarItems(trailing: 
  Toggle(isOn: $hideCancelled, label: { 
    Text("Hide Cancelled")
  })
)

P251
Image at bottom is missing the destructive reschedule now option in the action sheet

P259
They should be near line 125
They should be near line 118

P267
You’ll learn more about accessibility in Chapter 15, “Expanding the UI.”
Chapter 15 is not called Expanding the UI

P273
Chapter 16, " Expanding the UI "
There is no chapter 16 or a chapter called Expanding the UI

P278
No mention about opening the new starter project

P281
var id = UUID()
let id = UUID()

P282
You created a deck previously for the Practice feature of the app as a simple array of cards, but the Learn feature has different needs so you’re going to be more explicit with the how the deck words this time.

You created a deck previously for the Practice feature of the app as a simple array of cards, but the Learn feature has different needs so you’re going to be more explicit with the how the deck works this time.

I do not remember ever creating a deck as a practice feature earlier on.

P291
self.revealed = !self.revealed
self.revealed.toggle()

P294
Essentiallym this means the component would move right and up on the screen to match the motion of the users finger

Essentially this means the component would move right and up on the screen to match the motion of the users finger

p296
@GestureState var isLongPressed = false
@GestureState private var isLongPressed = false

P313
Open AirportAwards.swift and add the following code below the first award and above the spacer

There has been no Spacer added to AirportAwards

2 Likes

Thanks Piers, well spotted! I’ve fixed my chapters for the next update :+1:

Fully agreed. My sentiments are very much similar. Feeling confused while reading the chapter 7. The chapter 8 starts with chapter 6 “Finished” . The book needs some thorough review work or udpates in near future .

Hi,

I am going through Chapter 8. It seems the SwiftUI has some changes? I double check by running the final project. Here you can see the ‘remember me’. Even though it is .trailing the UI shows .leading

    Toggle(isOn: $userManager.settings.rememberUser) {
      Text("Remember me")
        .font(.subheadline)
        .multilineTextAlignment(.trailing)
        .foregroundColor(.gray)
    }
  }

55

Nice! As mentioned previously really appreciate RW and the authors of this book. Just want to help maintain RW standard as its the best place to learn iOS IMO and wished I had just known about and used RW and not gone to an expensive coding bootcamp to initially learn iOS.

Look forward to the updated edition.

1 Like

Chapter 3 - iBooks page 48 - embedding the top-level VStack in a NavigationView resulted in the view no longer being displayed in landscape view on an iPhone. For this to work properly, it seems that we need to set the NavigationViewStyle.

var body: some View {
NavigationView {
VStack { … }
}.navigationViewStyle(StackNavigationViewStyle())
}

1 Like

thanks! I noticed this today and I’ll fix it for the next update.

I think the change happened in a later beta…

I actually get better results with:

NavigationView {
  VStack {
     ...
  }
   .navigationBarTitle("", displayMode: .inline)
   .navigationBarHidden( true )
}

It doesn’t seem like you’d need both of these, but it doesn’t work if you comment out one or the other. And the navigation bar doesn’t really go away :frowning:.