I try to get an image in JSON, but how can I get the image into a NSData?
All I get is an __NSCFArray with my binary data, but how to convert it?
EDIT:
This is my result in json
Printing description of resDict:
{
Details = "Foo";
GroupingInfo = LRU;
HeaderLeft = "Bar";
HeaderRight = "Foo";
Id = "cb217aeb-14e3-4bd5-8895-3217238deb2c";
IsGray = 0;
AnotherId = "<null>";
MainImage = (
137,
80,
78,
71,
...
You first have to parse the JSON, then take the binary part, into NSData. UIImage has a method to do change NSData into image
Update : (hope no one minds)
After making myself such a demo, NSJSONSerialization always returns strings, and after having a small back and forth conversation below. I tried to send an image as a Base64 coded string and read back in as data using base64 decode. This works as a charm.
This is the code I use (since this works on all iOS versions, from 3.0 and up) :
NSData+PHBase64.h
NSData+PHBase64.m