【发布时间】:2010-05-09 23:38:52
【问题描述】:
我正在深入研究 iPhone 开发,所以如果这是一个荒谬的问题,我提前道歉,但是在一个使用 Core Data 框架的新 iPad 应用程序项目中,这里是生成的用于创建 persistentStoreCoordinator 的代码...
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"ApplicationName.sqlite"]];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
Typical reasons for an error here include:
* The persistent store is not accessible
* The schema for the persistent store is incompatible with current managed object model
Check the error message to determine what the actual problem was.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return persistentStoreCoordinator;
}
我的问题是……
- 我第一次运行应用程序时,如果ApplicationName.sqllite 数据库不存在,是否会自动创建它?如果没有,它是什么时候创建的?何时以编程方式将数据添加到其中?
- 一旦数据库确实存在,我在哪里可以找到该文件?我想用其他程序打开它,以便手动操作数据。
非常感谢您的帮助!我现在将继续研究这些问题。
【问题讨论】: