I can create UIImage from NSData using [UIImage imageWithData:] or [UIImage initWithData:] methods.
UIImage
NSData
[UIImage imageWithData:]
[UIImage initWithData:]
I wonder if I can get the NSData back from an existing UIImage? Something on the line of NSData *myData = [myImage getData];
NSData *myData = [myImage getData];
NSData *imageData = UIImageJPEGRepresentation(image, 0.7); // 0.7 is JPG quality
or
NSData *imageData = UIImagePNGRepresentation(image);
Depending if you want your data in PNG format or JPG format.
2.1m questions
2.1m answers
60 comments
57.0k users