Quantcast
Channel: How do I save a UIImage to a file? - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Answer by lu yuan for How do I save a UIImage to a file?

$
0
0

First you should get the Documents directory

/* create path to cache directory inside the application's Documents directory */NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"fileName"];

Then you should save the photo to the file

NSData *photoData = UIImageJPEGRepresentation(photoImage, 1);[photoData writeToFile:filePath atomically:YES];

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>