【发布时间】:2011-06-09 19:16:03
【问题描述】:
我正在使用 CoreData 构建一个 iOS 应用程序。我的一小部分用户(大约 1/1000)报告说应用程序在启动后不久就崩溃了。我怀疑持久存储协调器未能将数据库添加为持久存储。我无法重现测试中的任何错误,也无法从我的用户那里获得任何调试信息。有谁知道这种方法产生的任何常见错误?
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator_ != nil) return persistentStoreCoordinator_;
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"databasefile.sqlite"];
NSError *error = nil;
persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel];
if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return persistentStoreCoordinator_;
}
【问题讨论】: