How to add hyperlink in iPhone app?

It depends on where you want to put this link. If it is in a UITextView, you just have to enable it.

textView.text = @"Some text with link in it : http://http://stackoverflow.com";
textView.dataDetectorTypes = UIDataDetectorTypeLink;

More info on iOS reference library.

Or, if you want to open Safari programmatically:

NSURL *url = [ [ NSURL alloc ] initWithString: @"http://stackoverflow.com" ];
[[UIApplication sharedApplication] openURL:url];
[url release];

If you want to share on Facebook, you need to tell Safari to open a URL which will display a Facebook page that allows the user to share. Here is an example:

NSString *urlString = @"http://stackoverflow.com";
//The url you want to share

NSString *title = "The Title of the Page";
//The title you want to be displayed on Facebook

NSString *shareUrlString = [NSString stringWithFormat:@"http://www.facebook.com/sharer.php?u=%@&t=%@", urlString , title];
//Create the URL string which will tell Facebook you want to share that specific page 

NSURL *url = [ [ NSURL alloc ] initWithString:shareUrlString ];
//Create the URL object 

[[UIApplication sharedApplication] openURL:url];
//Launch Safari with the URL you created

[url release];
//Release the object if you don't need it

Drag a textView in your View Controller and select it's attribute inspector:

  1. Set your text as "My website: www.mywebsitelink.com" and make sure that text type should be plain.
  2. Tick your behavior as Selectable and not Editable.
  3. Tick on detection as Links.

Run your project. You can see link in View Controller. Click on link, that will take you to safari and open a new tab on it.