CoreData

Hi All, I'm very new to iOS app development. I've managed to complete the Scrumdinger tutorial. However, I would like to know how can I use CoreData or CloudKit to persist the data.

URL: https://developer.apple.com/tutorials/app-dev-training/persisting-data

I'm having trouble to bind the data to EditView(). Is there any online guide or tutorial that can help me?

Thank you!

Answered by kaviraja in 686183022

Found a solution to persist data in Edit Mode. In your Edit View

// Core Data Model
@ObservedObject var data: Data

// Your Text Field 
@State private var titleInput: String = ""

NavigationView {
   Form {
      TextEditor(text: $titleInput)
   }
}
.onAppear {
      self.titleInput = self.data.title
}

Found a guide in WWDC 2021: https://developer.apple.com/videos/play/wwdc2021/10017/

Accepted Answer

Found a solution to persist data in Edit Mode. In your Edit View

// Core Data Model
@ObservedObject var data: Data

// Your Text Field 
@State private var titleInput: String = ""

NavigationView {
   Form {
      TextEditor(text: $titleInput)
   }
}
.onAppear {
      self.titleInput = self.data.title
}

CoreData
 
 
Q