Core Data does not update

早过忘川 提交于 2019-12-25 05:10:28

问题


This is the sequence of steps I have taken:

  • Load data into table view
  • add new data
  • click to see more details on cells
  • load the details
  • edit details
  • press save
  • back to table view
  • everything is fine
  • re-open the application
  • nothing updated

I had this problem also with sqlite, and I didn't fix it. No, I am also stacked with CoreData.

-(IBAction)save:(id)sender
{
    [passwords setValue:nametxt.text forKey:@"name"];

    [passwords setValue:usernametxt.text forKey:@"username"];


}

-(void) viewWillAppear:(BOOL)animated
{
    self.title = passwords.name;

    nametxt.text = passwords.name;
    usernametxt.text = passwords.username;

}

回答1:


You need to call save method of your NSManagedObjectContext.

NSError *error = nil;
[managedObjectContext save:&error];
if (error) {
//inform user
}


来源:https://stackoverflow.com/questions/10868602/core-data-does-not-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!