I am trying to make a URL with a string using the following code
NSString *urlStr = [NSString stringWithFormat:@"http://demo.com"];
NSURL *url = [NSURL urlWithString:urlStr];
But the URL is always coming up nil. When I print description of the URL, I get:
Printing description of url:(NSURL *) url = 0xbfffdb78 (not an Objective-C object)
Can anyone help me and what am I missing?
Try this,
NSString *urlstr=[NSString stringWithFormat:@"http://google.com"];
urlstr = [urlstr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL * url=[NSURL URLWithString:urlstr];
NSURL或NSMutableURL的描述应以这种方式打印
NSLog(@"%@",url.absoluteString);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.