Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert NSData to a NSURL

I have seen this done the other way. But I have a NSData object returned that is suppose to be a URL of an image file.

How do I do this convert a NSData object into a NSURL?

Thanks

like image 360
elliotrock Avatar asked Jul 21 '11 15:07

elliotrock


Video Answer


1 Answers

You first need to convert the NSData object to an NSString object and then you can just create a NSURL with the new string.

 NSString *urlString = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding]; // Or any other appropriate encoding
 NSURL *url = [[NSURL alloc] initWithString:[urlString autorelease]];
like image 86
JustSid Avatar answered Sep 30 '22 10:09

JustSid