2

I like to save an image called img to the iTunes file sharing folder. Can someone please tell me how?

David Gölzhäuser
  • 3,525
  • 8
  • 50
  • 98

1 Answers1

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
    Keep in mind that you need to enable the iTunes Filesharing in xcode – arnoapp Apr 05 '13 at 12:30
  • 1
    Keep 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