I created my application. I need to open URL in iPhone, safari view directly.
My code 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, the Safari view is opened. But the URL is not opened. It is showing error. The error is
Cannot Open Page safari cannot open the page because the address is invalid
But the URL is opened in browser.
Does anyone know the solution, to open this URL in Safari in iPhone using Objective C?