How can I launch Safari from an iPhone app? How can I launch Safari from an iPhone app? ios ios

How can I launch Safari from an iPhone app?


should be the following :

NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"];if (![[UIApplication sharedApplication] openURL:url]) {    NSLog(@"%@%@",@"Failed to open url:",[url description]);}


UIApplication has a method called openURL:

example:

NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com"];if (![[UIApplication sharedApplication] openURL:url]) {  NSLog(@"%@%@",@"Failed to open url:",[url description]);}


you can open the url in safari with this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"]];