I'm communicating with a server in Swift retrieving image data. The incoming data is encoded as a base64 string. I am able to correctly receive and display the encoded strings. When I go to use the NSData
class to decode the string back to binary data and display...
println(NSData(base64EncodedString: imageString, options: NSDataBase64DecodingOptions(0)))
The output is
nil
nil
nil
nil
nil
nil
One for each of the images received.
I've also tried
println(NSData(base64EncodedString: imageString, options: nil))
and the same results. Is there anything I am missing along the way?? I would put the image strings up but they are massively long...
For others that may be having this issue, make sure your Base64 encoded string has a length divisible by 4 (=
should be used to pad the length).
See this StackOverflow answer here: https://stackoverflow.com/a/36366421/330494
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With