Monday, 18 February 2013

Convert Image to Base64 string in iOS

Add Base64 class www.imthi.com/wp-content/uploads/2010/08/base64.zip in your project Now encode as:


NSData* data = UIImageJPEGRepresentation(yourImage, 1.0f);
 [Base64 initialize];
 NSString *strEncoded = [Base64 encode:data];
Decode as:
 [Base64 initialize]; 
 NSData* data = [Base64 decode:strEncoded ];;
 image.image = [UIImage imageWithData:data];