Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURL URLWithString: giving nil

Tags:

iphone

nsurl

Please see the below code :

UIImage *image;
NSString *str = [[[Data getInstance]arrPic]objectAtIndex:rowIndex];
NSLog(str);
NSURL *url = [NSURL URLWithString:str];
NSData *data = [NSData dataWithContentsOfURL:url];
image = [UIImage imageWithData:data];  

str is giving me http://MyDomain/Pics\\1.png but url is giving me nil.

like image 351
Nitish Avatar asked Nov 29 '22 03:11

Nitish


1 Answers

Just try using this,

[NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
like image 84
Mehul Mistri Avatar answered Dec 09 '22 17:12

Mehul Mistri