I have some NSData
which is Base-64 encoded and I would like to decode it, I have seen an example that looks like this
NSData* myPNGData = [xmlString dataUsingEncoding:NSUTF8StringEncoding];
[Base64 initialize];
NSData *data = [Base64 decode:img];
cell.image.image = [UIImage imageWithData:myPNGData];
However this gives me a load of errors, I would like to know what to do in order to get this to work. Is there some type of file I need to import into my project or do I have to include a framework?
These are the errors I get
Use of undeclared identifier 'Base64'
Use of undeclared identifier 'Base64'
Use of undeclared identifier 'cell'
I have looked everywhere and cannot figure out what is the proper thing to do.
This will work for ios7 and above.
And use the code like this:
NSData Base64 library files will help you.
Hope it helps
Swift 3 Version
It's pretty much the same
Swift 2.3 Version
You can decode a Base64 encoded string to
NSData
:Example use of above method to get an image from the Base64 string:
Swift 3 version
Use type Data instead of NSData