Try these two methods.they are both from here:how to decode BASE64 encoded PNG using Objective C
You can decode it to NSData using this:
-(NSData *)dataFromBase64EncodedString:(NSString *)string{
if (string.length > 0) {
//the iPhone has base 64 decoding built in but not obviously. The trick is to
//create a data url that's base 64 encoded and ask an NSData to load it.
NSString *data64URLString = [NSString stringWithFormat:@"data:;base64,%@", string];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:data64URLString]];
return data;
}
return nil;
}
Then use this to get the image:
-(void)imageFromBase64EncodedString{
NSString *string = @""; // replace with encocded string
NSData *imageData = [self dataFromBase64EncodedString:string];
UIImage *myImage = [UIImage imageWithData:imageData];
// do something with image
}
2nd method you can use:
You can download class files from http://projectswithlove.com/projects/NSData_Base64.zip
Then #import "NSData+Base64.h"
put this is your code
NSData *data = [[NSData alloc] initWithData:[NSData dataWithBase64EncodedString:strData]];
You can now convert to UIImage
UIImage *image = [UIImage imageWithData:data];