2011-10-14 36 views

回答

3

首先,设置Application supports iTunes file sharing对你的项目的设置plist。它也可以被命名为UIFileSharingEnabledenter image description here

然后,代码,文件保存在NSDocumentDirectory像这样:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Id its a local file in the app use its name. If not, alter for your needs. 
    NSString *fileName = @"someFile.png"; 
    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSError *error; 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:fileName]; 
  
    if (![fileManager fileExistsAtPath:documentDBFolderPath]) { 
     NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName]; 
     [fileManager copyItemAtPath:resourceDBFolderPath toPath:documentDBFolderPath error:&error]; 
    } 
    [self.window makeKeyAndVisible];  
    return YES; 
} 

iOS Dev Tips - File Sharing from App to iTunes is too easy

+0

请看下面sho的回答,你不需要启用文件共享。 –

4

Organizer

使用下载按钮,在主办单位允许您将所有拍摄将.xcappdata包保存到您的Mac(Xcode 4.2,以前的版本只保存一个文件夹)。您可以右键单击并选择“显示包装内容”,Finder窗口将打开,您可以在其中找到Documents目录的副本。

相关问题