Errata for SwiftUI by Tutorials 1st Edition

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

Chapter 3 page 72 "“Then remove the padding from the HStack in ColorSlider.swift, so the view looks like this:” Should ColorSlider.swift be listed as ContentView.swift?

hi Kenny! thanks for noticing this — it should be “the ColorSlider view”. I’m not sure how that .swift got in there :confused:

the correction will be in the next update.

Thanks a lot for reporting all these errors. I’ve updated my chapters

1 Like

Thanks for reporting this. The text alignment is actually superfluous here, because the Text is sized to fit its content, so there’s no alignment at all, at least as long as the text is on a single line. I’ve removed that line from both the project and the code snippet in the book.

What changed instead is the behavior of the Spacer() that precedes the Toggle(): it should “push” the toggle, and the text label it contains, to the right, as shown in the corresponding screenshot included in the book - It looks like the spacer behavior has changed with the latest Xcode release (either 11.0 or 11.1), now the spacer has a small fixed width instead.

Thanks for your hard work. Learn’t a lot from your chapters.

1 Like

Minor typo but the title page for the “complex interfaces” chapter says chapter 14, when it should say chapter 15. That also means I’m almost done :wink:

congratulations Darrell!

the chapter title is correct in version 1.0.1

Chapter 2, page 24. Create a new project screenshot: “Use SwiftUI” is no longer a checkbox.

thanks! I’ll fix it for the next update.

Do you know more or less when the next update will be available?