Missing Step in iOS App Dev Tutorial > SwiftUI > Passing Data With Bindings

This is not a question, but rather the solution and an explanation of a missing step in the iOS App Dev Tutorial. I hope this helps somebody else encountering the same issue and ultimately leads to a change to the tutorial.

There is a step missing from the iOS App Dev Tutorial under the Passing Data with Bindings part in Section 3 before Step 6. Namely, the update function has not been defined on the DailyScrum struct. This results in the following errors in DetailView.swift when calling scrum.update(from: data):

Argument passed to call that takes no arguments
Cannot use mutating member on immutable value: 'self' is immutable
Referencing instance method 'update()' requires wrapper 'Binding<DailyScrum>'

The files for the complete project at the end of the Passing Data with Bindings part provides the solution: you must add an update function to the DailyScrum model.

Add the following inside the extension DailyScrum code block:

   mutating func update(from data: Data) {
      title = data.title
      attendees = data.attendees
      lengthInMinutes = Int(data.lengthInMinutes)
      theme = data.theme
  }

When complete, your DailyScrum.swift file should appear as follows at this stage in the tutorial.

import Foundation

struct DailyScrum: Identifiable {
  let id: UUID
  var title: String
  var attendees: [Attendee]
  var lengthInMinutes: Int
  var theme: Theme
   
  init(id: UUID = UUID(), title: String, attendees: [String], lengthInMinutes: Int, theme: Theme) {
    self.id = id
    self.title = title
    self.attendees = attendees.map { Attendee(name: $0) }
    self.lengthInMinutes = lengthInMinutes
    self.theme = theme
  }
}

extension DailyScrum {
  struct Attendee: Identifiable {
    let id: UUID
    var name: String
     
    init (id: UUID = UUID(), name: String) {
      self.id = id
      self.name = name
    }
  }
   
  struct Data {
    var title: String = ""
    var attendees: [Attendee] = []
    var lengthInMinutes: Double = 5
    var theme: Theme = .seafoam
  }
   
  var data: Data {
    Data(title: title, attendees: attendees, lengthInMinutes: Double(lengthInMinutes), theme: theme)
  }
   
  mutating func update(from data: Data) {
    title = data.title
    attendees = data.attendees
    lengthInMinutes = Int(data.lengthInMinutes)
    theme = data.theme
  }
}

extension DailyScrum {
  static let sampleData: [DailyScrum] =
  [
    DailyScrum(title: "Design", attendees: ["Cathy", "Daisy", "Simon", "Jonathan"], lengthInMinutes: 10, theme: .yellow),
    DailyScrum(title: "App Dev", attendees: ["Katie", "Gray", "Euna", "Luis", "Darla"], lengthInMinutes: 5, theme: .orange),
    DailyScrum(title: "Web Dev", attendees: ["Chella", "Chris", "Christina", "Eden", "Karla", "Lindsey", "Aga", "Chad", "Jenn", "Sarah"], lengthInMinutes: 5, theme: .poppy)
  ]
}

I added your code, however I still have the following errors: ScrumsView.swift


                                Button("Add") {

                                    

                                    let newScrum = DailyScrum(data: newScrumData)

                                    scrums.append(newScrum)

                                    isPresentingNewScrumView = false

                                    newScrumData = DailyScrum.Data()

                                    

                                    

                                }

                            }

Thank you so much

Thank you, saved me a big headache trying to figure out what I'd done wrong!

Thank God for you. I thought I was going crazy.

Thank you! I also thought I was losing my mind. I went over the code about 20 times and could not figure out what I was doing wrong. Glad I decided to google this!

yo @matthewheck ur a king bro👑 i literally just started writing in swift/swiftui this week and i've been pullin all nighters all day lol bustin thru all the tuts and shi but i was just about done with this scrumdinger app and i was about to lose my f'ing mind trying to fig out what was going on with the 3 errors i was getting on the scrum.update .. i literally would have paid you to share this info fam, big bless and keep grindin THANK YOU!!!! 🙏 💰

saved me 100 hours of troubleshooting.. THANK YOU

Thanks, it helps me a lot !

Missing Step in iOS App Dev Tutorial &gt; SwiftUI &gt; Passing Data With Bindings
 
 
Q