Ranjeet Sajwan
Ranjeet Sajwan

Reputation: 1921

Making an UIImage from byte string

I am paring a XML and getting an image in Byte form and I have put that in a string. Now I have to draw that image.

I have tried to use various methods but no success. How can I do this?

Upvotes: 0

Views: 1626

Answers (2)

Mick Walker
Mick Walker

Reputation: 3847

Try converting the string to NSData:

NSString* str= ....
NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding]; 

Then take a look at:

UIImage *image = [[UIImage alloc] initWithData:data]; 

Hope this helps.

Upvotes: 3

visakh7
visakh7

Reputation: 26390

You can convert the byte into NSData and then you can get the image using

UIImage *image = [[UIImage alloc] initWithData:data];

OR

UIImage *image = [UIImage imageWithData:data];

Upvotes: 2

Related Questions