如何在coredata和xcode中插入多个/顺序的新行?
-(void)LoadDB{
CoreDataAppDelegate *appdelegate = [[UIApplication sharedApplication]delegate];
context = [appdelegate managedObjectContext];
NSManagedObject *newPref;
newPref = [NSEntityDescription
insertNewObjectForEntityForName:NSStringFromClass([Preference class])
inManagedObjectContext:context];
NSError *error;
[newPref setValue: @"0" forKey:@"pid"];
[context save:&error];
[newPref setValue: @"1" forKey:@"pid"];
[context save:&error];
}
Run Code Online (Sandbox Code Playgroud)
刚刚结束的代码写入了上一个条目.插入下一行的正确程序是什么?