用真机调试代码,用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打开时候找不到这个文件夹? |
|
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. |