If you have an image inside a UIImageView , e.g. "myImageView", you can do the following:
Convert your image using UIImageJPEGRepresentation() or UIImagePNGRepresentation() like this:
NSData *data = UIImagePNGRepresentation(myImageView.image);
//or
NSData *data = UIImageJPEGRepresentation(myImageView.image, 0.8);
//The float param (0.8 in this example) is the compression quality
//expressed as a value from 0.0 to 1.0, where 1.0 represents
//the least compression (or best quality).
You can also put this code inside a GCD block and execute in another thread, showing an UIActivityIndicatorView during the process ...
//*code to show a loading view here*
dispatch_queue_t myQueue = dispatch_queue_create("com.my.queue", DISPATCH_QUEUE_SERIAL);
dispatch_async(myQueue, ^{
NSData *data = UIImagePNGRepresentation(myImageView.image);
//some code....
dispatch_async( dispatch_get_main_queue(), ^{
//*code to hide the loading view here*
});
});