The idea is to give to users an access to files from applications. For example, a file is downloaded or new one is created on the iPad and user wants to use it on the desktop then.
- Set “Application supports iTunes file sharing” on on your project’s settings plist. It could also be named with “UIFileSharingEnabled“.
- Add a file and remember its name. I’ve added “Alterplay.gif” – Alterplay logo from our Basecamp account.
3. Code
Copy file to “/Documents” on application run:
- (BOOL)application:(UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions { // Override point for customization after application launch. // file sharing trying { NSString *fileName = @"Alterplay.gif"; 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;}
To prove:
- run on your iPhone
- close the app
- open iTunes and go to the apps section to the bottom
- select “FileSharingSample” and see/copy the file


