尝试更新一些核心数据。数据实际上是在“某处”更新,但它没有保存/更新数据库。
- (IBAction)Update:(id)sender {
NSEntityDescription *entityDesc =
[NSEntityDescription entityForName:@"Preferences"
inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDesc];
NSError *error;
NSArray *objects = [context executeFetchRequest:request
error:&error];
if ([objects count] == 0) {
// No update, didnt find any entries.
} else {
for (NSManagedObject *obj in objects) {
[obj setValue:_salesPrice.text forKey:@"value"];
if(![context save:&error]){
NSLog(@"Saving changes failed: %@", error);
}
}
}
//[context save:&error];
}
我已经[context save:&error];
在评论区尝试过,但仍然没有保存。保存时我也没有错误。