Mughees Musaddiq
Mughees Musaddiq

Reputation: 1060

Decode base64 string for image

I have encoded string in base64 and want to decode it but getting nil in NSData *decodedData. NSString *images contains encoded string.

NSString *images = encoded string;
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:images options:0];
UIImage *myImage = [UIImage imageWithData:decodedData];

Upvotes: 0

Views: 142

Answers (1)

Zev Eisenberg
Zev Eisenberg

Reputation: 8168

Perhaps you have unknown characters? Try passing NSDataBase64DecodingIgnoreUnknownCharacters into the options: parameter.

Upvotes: 2

Related Questions