views:

81

answers:

1

Trying to figure out how to load an external webpage into my iPhone app. It would be used to let people know the latest of something.

Here's what I have found but I am unaware of how to use it:

NSData *externalData = [NSData dataWithContentsOfURL:[NSURL URLWithString: @"http"//www.xprogress.com/time.php"]]

How would I load this into a xib file so that it shows up in the app? Or where would I find a tut on how to do this?

A: 

It depends on whats in the URL for you to be able to display it, technically you can just convert the data to an NSString and then hook it up to an IBOutlet UILabel in a xib.

But you probably want more functionality than that. Have a look at a generic RSS reader like this one. It's not great but might get you started. Typically you would want the URL to transfer data in some kind of structured form like XML and then use NSXMLParser to build it into an Array of dictionaries then hook that up to a UITableView, which is what the tutorial sort of demonstrates.

Rudiger
Thanks. I wouldn't want to load in a feed though. I would like to load in just maybe one line that is a link. Like a blurb, kind of how "Words with Friends" does in their app where it changes from "Followus on Twitter" to "Be a fan on facebook" or some other news thing they want to share with everyone.
Josh Lee
If its just a url then just convert NSData to NSString have a look here http://stackoverflow.com/questions/550405/convert-nsdata-bytes-to-nsstring. Once its a NSString you can link it to open safari, example here http://stackoverflow.com/questions/822599/launch-safari-from-iphone-app
Rudiger
Nice thanks. I will check it out.
Josh Lee