Reputation: 3
I'm studying Swift Tutorial; iOS App Dev Tutorials.
At State Management, Updating App Data Section 2 Step 1, Step 3, Step 4, There's an error here.
I've been googling it for two hours, but I can't find it. Please, Help me!
Other errors have been googling, finding problems or solutions.
.onDisappear {
scrumTimer.stopScrum()
let newHistory = History(attendees: scrum.attendees, lengthInMinutes:
scrumTimer.secondsElapsed / 60)
scrum.history.insert(newHistory, at: 0) // <- These is an error here.
}
There are three error messages.
Cannot call value of non-function type 'Binding'
Referencing subscript 'subscript(dynamicMember:)' requires wrapper 'Binding'
Value of type 'DailyScrum' has no dynamic member 'history' using key path from root type 'DailyScrum'
Section(header: Text("History")) {
if scrum.history.isEmpty { // <- These is an
// error here.
Label("No meeting yet", systemImage:
"calendar.badge.exclamationmark")
}
ForEach(scrum.history) { history in // <-
// These is an error here.
HStack {
Image(systemName: "calendar")
Text(history.date, style: .date)
}
}
}
I think it's an error due to the same cause.
Upvotes: 0
Views: 851
Reputation: 10422
You’ve not done anything wrong, other than fail to notice something which Apple doesn't make clear in their tutorial.
Unlike many step-by-step tutorials, the code you end up with when you finish a chapter of that tutorial isn't the same as the starting code in the next chapter.
So, when you finish the chapter on Managing State and Life Cycle, DailyScrum
has the properties:
let id: UUID
var title: String
var attendees: [String]
var lengthInMinutes: Int
var color: Color
But if you download the code for the next chapter, Updating App Data, the starting project has expanded DailyScrum
and added a new History
object:
let id: UUID
var title: String
var attendees: [String]
car lengthInMinutes: Int
var color: Color
var history: [History]
Unless you're making your own modifications to the code outside of what the tutorial suggests, I'd recommend ditching your working project at the end of each chapter and extracting the StartingProject
from the ZIP file at the head of ech new chapter. That way you should be able to follow along without always worrying about what new code Apple has slipped in between chapters.
Upvotes: 1