problem with loading a url into safari
I am using the below code to load a url into safari (iphone):
开发者_StackOverflowNSString *gotoURL = [self getPostID:indexPath.row];
//NSLog(gotoURL );
NSURL *url = [ [ NSURL alloc ] initWithString:gotoURL];
[[UIApplication sharedApplication] openURL:url];
the code works if I replace gotoURL with : @"http://www.example.com" but it wont if I replace it.
The gotoURL gets a url from getPostID (which also returns a NSString) and I did an nslog as you can see and the url format seems fine.
Any idea why its not working?
From what you've added, it is likely that you're missing the protocol in the url. The string passed must be http://domain.tld/4Mi
.
精彩评论