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

shelly 2015-02-15 04:06:49
用真机调试代码,用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里面,找不到文件。
有没有人懂的?先谢谢啦。
...全文
148 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zioc2014 2015-02-15
  • 打赏
  • 举报
回复
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.

29,049

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧