如何在coredata和xcode中插入多个/连续的新行?添加多个/连续的行 - 在Coredata中填充数据库
-(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];
}
刚刚结束的代码写入了前一个条目。插入下一行的正确步骤是什么?
Doc是你的朋友。 https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdCreateMOs.html –
根据我的经验,苹果文档更多的是你在家庭聚会时被迫与之互动的表弟,对任何人都不是真正的朋友。 –
准确@MechIntel – llBuckshotll