简体   繁体   中英

Base64 encoded string wont decode (iOS)

I am base64 encoding some data using the following line:

NSString *theData = [serialized base64EncodedStringWithOptions:kNilOptions];

This works correctly and I then pass this string to my web server which stores it in the database.


Later, I am then retrieving this base64 encoded string back from the web server which also works correctly (I have compared both the original before upload and the after download strings and they are the same).

However, when I try to decode this string using:

NSString *theString = [imageDict objectForKey:@"image"];
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:theString
                                                        options:kNilOptions];

it just gives me a null value for imageData .

If I output theString it is the correct base64 encoded string I uploaded.


Any ideas why it won't decode?

Thanks in advance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM