问题
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