user2211011
user2211011

Reputation:

how to convert and run string to image (base64) xcode

I want get string of image in way base64 from (php file) in server.

but I don't know what decode this string and convert to image and display in UIImage.

Upvotes: 3

Views: 3795

Answers (2)

Vishnuvardhan Sadu
Vishnuvardhan Sadu

Reputation: 87

NSData* data = UIImageJPEGRepresentation(yourImage, 1.0f);

 NSString *strEncoded = [Base64 encode:data];

Decode as:

 NSData* data = [Base64 decode:strEncoded ];;
 image.image = [UIImage imageWithData:data];

Upvotes: 1

Hari1251
Hari1251

Reputation: 452

NSURL *urlString = [NSURL URLWithString:@"your string"];

NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation([UIImage imageWithData:

[NSData dataWithContentsOfURL:urlString]])];

UIImage *image = [UIImage imageWithData:imageData];

Try this.....may be use full for u.

Upvotes: 1

Related Questions