ios - Core Data not Persisting -
i'm having problem core data. have table view viewcontroller1
populated array populated data in core data model. when cell selected, push segue viewcontroller2
, can view saved data. there, have button called "edit" that, when selected, modal segue viewcontroller3
can edit data. here's code have saving edited data.
//editmodel [self.editmodel setvalue:self.editnametextfield.text forkey:@"name"]; [self.editmodel setvalue:self.edittextview.text forkey:@"text"]; [self.editmodel setvalue:[nsdate date] forkey:@"date"]; nserror *error; if (![[self.delegate managedobjectcontext] save:&error]) { nslog(@"can't save edit: %@", [error localizeddescription]); } if (self.delegate) [self.delegate dismissedit:self]; else nslog(@"there no delegate");
however, whenever try calling this, nslog: can't save edit: (null)
viewcontroller2
reflects change; table view in viewcontroller1
. but, when quit ios simulator , run again, data previous editing process. help?
most managed object context isn't being made available delegate
. rather delegate
, each managed object has link managed object context added can do:
[self.editmodel.managedobjectcontext save:&error]
Comments
Post a Comment