I am playing around with a new project, a split view iPad app using Core Data, and I was wondering, as its fairly clear how to add and remove an item. If I was to say alter this to hold text, then that text be shown in a UITextView, how can I edit or overwrite an object in CoreData?
So the user types their note in the UITextView and when they leave that it edits and saves the note (object in the table view) they have currently selected.
Appreciate any help thanks.
You simply request the existing object using an
NSFetchRequest, change whatever fields need to be updated (a simple myObject.propertyName setter is all that’s required), and then perform a save action on the data context.EDIT to add code example. I agree with MCannon, Core Data is definitely worth reading up about.
This code assumes you created the project with a template that includes Core Data stuff, such that your app delegate has a managed object context, etc. Note that there is NO error checking here, this is just basic code.
Fetching the object
Update the object
Save the change
Now your object/row is updated.