Here is my code.
UIImage *img = [UIImage imageNamed:@\"white.jpeg\"];
NSData *imageData = UIImagePNGRepresentation(img);
NSString *imageString = [imageData
I think you should replace the your options parameter
Change:
NSString *imageString = [imageData base64EncodedStringWithOptions:0];
To:
NSString *imageString = [imageData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
And just in case you'd like it:
- (NSString *)imageToNSString:(UIImage *)image
{
NSData *data = UIImagePNGRepresentation(image);
return [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
}
- (UIImage *)stringToUIImage:(NSString *)string
{
NSData *data = [[NSData alloc]initWithBase64EncodedString:string options:NSDataBase64DecodingIgnoreUnknownCharacters];
return [UIImage imageWithData:data];
}
Remember that this is an iOS 7 api.