Objective c iOS 8 Can';使用CoreData时无法定位sqlite文件
我用我的iPhone来运行这个项目。 这是我的密码:Objective c iOS 8 Can';使用CoreData时无法定位sqlite文件,objective-c,sqlite,core-data,Objective C,Sqlite,Core Data,我用我的iPhone来运行这个项目。 这是我的密码: NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, N
NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *dataStorePath = [documentPath stringByAppendingPathComponent:@"NewsData.sqlite"];
NSURL *dataStoreURL = [NSURL fileURLWithPath:dataStorePath];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:dataStorePath];
NSLog(@"%@",fileExists);
sqlite3 *db;
if (sqlite3_open([dataStorePath UTF8String], &db) != SQLITE_OK) {
sqlite3_close(db);
}
Bool类型“fileExists”为true,但当我使用Finder查找sqlite文件时,它不起作用。
有人能帮我吗?提前感谢。当您在iPhone上运行该文件时,您无法直接访问该文件,因为路径
数据存储路径
在您的设备上
您可以通过Xcode下载应用程序容器:首先连接您的iPhone。然后进入菜单中的Xcode->Window->Devices并选择左侧的iPhone。您的应用程序应出现在“已安装的应用程序”列表中。选择它并单击设置按钮(添加和删除按钮旁边),然后单击“下载容器…”。Xcode将询问您要将其保存到哪里。然后在finder中右键单击下载的容器并选择“显示包内容”。转到AppData->Documents,您将看到您的sqlite文件“NewsData.sqlite”
顺便说一下,如果你在模拟器中运行,你可以直接用finder打开链接 非常感谢,通过您的步骤,问题解决了。