How to Open a URL in Safari

Dec 1, 2009   //   by Derek van Vliet   //   Development  //  5 Comments

1Tis the season to broaden your iPhone dev chops! We have been developing on the iPhone platform for about 6 months now and it turns out that in that time, you tend to learn lots of little tips and tricks. Since we’re overcome by the spirit of giving around this time of year, we are going to be posting 24 of these bite-sized iPhone development tips, 1 every day between now and Christmas day. Consider it an advent calendar of iPhone dev tip goodies.

On With The First Tip!

Say you would like to open a URL in Safari. We used this on the “Get Set” button on the main menu of Addicus. Here is how to do it with just one line of code using the UIApplication class:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@""]];


  • […] Like other phones, the iPhone supports the tel application protocol in URLs. This means that all we need to use is the trusty openURL method of the UIApplication class. We have previously discussed this method when pre-composing emails and, believe it or not, opening a URL. […]

  • […] How to Open a URL in Safari 2. How to Show an Alert with UIAlertView 3. How to Display an Activity Indicator with […]

  • […] tips range from how to simply open a URL in Mobile Safari to more complicated tasks like string comparison using NSString. The tutorials are clear, easily […]

  • […] different versions of all of our iPhone games. To do this, we combine the above code with code that opens a URL. Here is the resulting code: NSString *appName = [[NSBundle mainBundle] […]

  • cool

Leave a comment

Our Games