Reputation: 252
I have fetched UIImage from photos library in ipad using UIImagePickerController. Now I want to save that image in a directory that is associated with my app and contains already added images. I have also got the url of the directory.
For example : file://localhost/Users/administrator/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/31816EF9-AE1E-40DF-93C4-C67A82E4B85B/Documents/7884/Images/
How can I save uiimage in the specified directory?
Upvotes: 0
Views: 1262
Reputation: 46543
Use this code to save it into your Document Directory.
NSData *pngData = UIImagePNGRepresentation(image);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.png"];
[pngData writeToFile:filePath atomically:YES];
Upvotes: 1