I use
[[NSData alloc] initWithBase64EncodedString:content options:0];
to load binary data that is passed over network, as a key of a JSON object. Sometimes it works, but in others it fails, like with this string.
This is a string created on the other end by NSData
itself:
[data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
Is there any option I have to pass, and why is it returning nil? String has multiple of 4 length and no weird characters, so I don't see why it fails?
I read the docs again, specifically this part:
The default implementation of this method will reject non-alphabet characters, including line break characters. To support different encodings and ignore non-alphabet characters, specify an options value of NSDataBase64DecodingIgnoreUnknownCharacters.
The fact that it rejects characters means that it will reject the whole string because of those characters apparently, because when I added NSDataBase64DecodingIgnoreUnknownCharacters
to the initializer options, it worked even with the mentioned string.