I am trying to convert a Base64 image to an UIImage
in Objective C
.
I am doing something like so :-
(UIImage *)decodeBase64ToImage:(NSString *)strEncodeData {
NSData *data = [[NSData alloc]initWithBase64EncodedString:strEncodeData options:NSDataBase64DecodingIgnoreUnknownCharacters];
return [UIImage imageWithData:data];
}
But this function always returns nil
.
My Base64 string is like so :-
I verified the validity of the image using https://codebeautify.org/base64-to-image-converter# and it displayed fine.
EDIT
P.S I also include the data:image/png;base64
in the string.
Is there a way I can fix this? Any help is appreciated.