无法在iTunes中查看SQLite文件

- (void) copyDatabaseIfNeeded { BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:ABC.Sqlite]; success = [fileManager fileExistsAtPath:writableDBPath]; if (success) return; // The writable database does not exist, so copy the default to the appropriate location. NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:ABC.Sqlite]; success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error]; if (success) { NSURL *url=[NSURL URLWithString:WSURL2]; } else { NSLog(@"Failed to create writable database file with message '%@'.", [error localizedDescription]); } } 

我需要添加任何代码来查看Sqlite文件?

我尝试在UIFileSharingEnabled添加这些: UIFileSharingEnabledCFBundleDisplayName

我如何在iTunes中查看我的SQLIte文件?

推荐链接: 如何为我的应用程序启用文件共享? , UIFileSharingEnabled没有效果

如果我在我的应用程序中启用了iTunes文件共享选项来备份PC中的应用程序数据,appStore是否会拒绝该应用程序?

您不是在Documents目录中创build文件,而是在Library目录中创build文件:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); // ^^^^^^^^^^^^^^^^^^ 

你想要NSDocumentDirectory