سؤال

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

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top