In a WebService JSON response is coming. In the response, there is image is coming as a byte array. I have to show the image in a UIImageView. I am trying to convert the byte array to NSData. But not getting how to do that. Any help would be appreciated.
I am confident that the byte array has image data in it.
Sample Byte array for your reference:
unsigned char array = {
137,
80,
78,
71,
...
66,
96,
130
};
Thanks
You have to convert the JSON to an array of strings first; you can, for example, use the
NSJSONSerializationclass:Then walk the strings array, convert each entry to an integer, and add it to an allocated byte pointer/array:
Then finally make an NSData out of the bytes, then init an UIImage object using it: