如何在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