views:

133

answers:

2

How to convert UIimage to base64 encoded string. i couldn't find any examples or codes with detailed regarding.......

+5  A: 

I wonder why didn't you find your question because it's a very old question & can be found here

http://stackoverflow.com/questions/392464/any-base64-library-on-iphone-sdk

http://discussions.info.apple.com/message.jspa?messageID=11852410

Anyways, You need to first to add NSData categories to your project which available from here - http://svn.cocoasourcecode.com/MGTwitterEngine/NSData+Base64.h

http://svn.cocoasourcecode.com/MGTwitterEngine/NSData+Base64.m

Then convert your UIImage object into NSData using following way:

NSData *imageData = UIImageJPEGRepresentation(image, 1.0);

And then apply Base64 encoding to convert it into base-64 encoded string

NSString *encodedString = [imageData base64Encoding];
Sagar
NSString *encodedString = [imageData base64Encoding];
apple
A: 

I also wrote about this in my sometimes dev blog: http://cluebucket.com/blog/2010/10/05/using-a-uiimage-directly-in-your-uiwebview/

There are several base64 categories available, be sure that you use one that is licensed to meet your needs.

TomH