I created my application. I need to open the url in iPhone, view the safari directly.
My code is as follows:
NSString *email = [NSString stringWithFormat:@"http://itunes.apple.com/us/album/music/id186152317?i=186153149&uo=4"];
email = [email stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [NSURL URLWithString:email];
if (![[UIApplication sharedApplication] openURL:url])
NSLog(@"%@%@",@"Failed to open url:",[url description]);
[super viewDidLoad];
But my problem is that Safari opens. But the url is not opening. It shows an error. Error
Cannot open the page. Safari cannot open the page because the address is invalid.
But the url opens in the browser.
Does anyone know a solution to open this url in Safari on iPhone using Objective-C?
source
share