Question

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top