I like to save an image called img
to the iTunes file sharing folder. Can someone please tell me how?
Asked
Active
Viewed 1,503 times
2

David Gölzhäuser
- 3,525
- 8
- 50
- 98
-
1If you simply store your img in Document Directory it will be visible in iTunes File Sharing. – βhargavḯ Apr 05 '13 at 11:45
-
http://stackoverflow.com/questions/2264039/uiimage-saving-image-with-file-name-on-the-iphone – B.S. Apr 05 '13 at 11:46
-
Do you want something like this http://www.raywenderlich.com/1948/how-integrate-itunes-file-sharing-with-your-ios-app – Satheesh Apr 05 '13 at 11:52
-
@George OK, can you please tell me where to place the file, so the file is visible in iTunes? – David Gölzhäuser Apr 05 '13 at 11:58
1 Answers
2
Here is sample code:
NSArray paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@.jpg", documentsDir, filename];
NSData data = UIImageJPEGRepresentation(img, 1.0);
[data writeToFile:filePath atomically:NO];
Also about iTunes file sharing:
You should go to Info.plist
and add row
Application supports iTunes file sharing
to YES

B.S.
- 21,660
- 14
- 87
- 109
-
1
-
1Keep in mind that if you enable that `info.plist` key and don't mention it anywhere in the app or iTunes app description, your app will get rejected. – Desdenova Apr 05 '13 at 13:17