"Convert image to/from text (Base64)"

Sun 14 March 2010

#import "NSDataAdditions.h"

 
 
 

-(NSString *)getStringFromImage:(UIImage *)image{

if(image){

NSData *dataObj = UIImagePNGRepresentation(image);

return [dataObj base64Encoding];

} else {

return @"";

}

}
 
//Convert back 

NSData *dataObj = [NSData dataWithBase64EncodedString:beforeStringImage];

UIImage *beforeImage = [UIImage imageWithData:dataObj];

 

NSDataAdditions.zip (2.80 kb)