0
我正在關注this核心數據教程和一件事讓我感到困惑。比方說,我做的事:瞭解核心數據保存
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *failedBankInfo = [NSEntityDescription
insertNewObjectForEntityForName:@"FailedBankInfo"
inManagedObjectContext:context];
[failedBankInfo setValue:@"Test Bank" forKey:@"name"];
[failedBankInfo setValue:@"Testville" forKey:@"city"];
[failedBankInfo setValue:@"Testland" forKey:@"state"];
NSManagedObject *failedBankDetails = [NSEntityDescription
insertNewObjectForEntityForName:@"FailedBankDetails"
inManagedObjectContext:context];
NSError *error;
if (![context save:&error]) {
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
}
我讀過CoreData實際上不用於存儲數據,但對管理,及CoreData的後備存儲的SQLite。那麼當應用程序會話終止時,上面添加的這些數據會發生什麼?當我運行上面的代碼時,數據是否會自動保存到某個SQLite文件中?或者,每次啓動應用程序時都會清空核心數據,除非我遵循一些填充它的特定操作?
我看到這個詞'堅持'與核心數據很多,但不明白究竟是什麼意思.. – Snowman 2012-03-03 20:32:51
堅持是保存在這樣的方式,它可以再次檢索。 – FluffulousChimp 2012-03-03 20:37:35