iOS8 使用coredata 时,找不到sqlite文件

iOS 码拜 9年前 (2015-05-03) 1366次浏览 0个评论

用真机调试代码,用coredata框架创建sqlite文件,下面是我的部分代码:

 
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        NSString *dataStorePath = [documentPath stringByAppendingPathComponent:@"NewsData.sqlite"];
        
        BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:dataStorePath];
        NSLog(@"%@",fileExists);
        sqlite3 *db;
        if (sqlite3_open([dataStorePath UTF8String], &db) != SQLITE_OK) {
            sqlite3_close(db);
 

我把dataStorePath 用Finder打开时候找不到这个文件夹?
fileExists 等于Yes
现在我找不到这个sqlite文件,dataStorePath 输出 等于 /var/mobile/Containers/Data/Application/4D13D2C2-30BB-414D-9699-A16DC6B2FA8D/Documents/NewsData.sqlite
然后我粘贴到Finder里面,找不到文件。
有没有人懂的?先谢谢啦。

iOS8 使用coredata 时,找不到sqlite文件
40分
When you run it on your iPhone you can””t access the file directly because the path dataStorePath is on your device.

What you can do is that you download the app container via Xcode: First connect your iPhone. Then go to Xcode->Window->Devices in the menu and select your iPhone on the left side. Your app should appear in the “Installed Apps”-list. Select it and click on the settings button (next to the add and delete button) and click on “Download Container…”. Xcode will ask you where you want to save it. Afterwards do a right click on the downloaded container in the finder and select “Show Package Contents”. Go to AppData->Documents and you will see your sqlite file “NewsData.sqlite”.

By the way, if you run in the simulator you can open the link directly with the finder.


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iOS8 使用coredata 时,找不到sqlite文件
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!