info : How to make an iphone app read data from internet

2k views Asked by At

I want to develop an iPhone app that read data from the internet but I have no idea about how to put the data over the internet (simple web , server or a specific things for iphone) and how to fetch the data inside the app ...

I describe myself as Intermediate level in Database

Note: All I need from where start learning how to develop something like this

Thank you

Cheer Bob

3

There are 3 answers

2
Aurum Aquila On BEST ANSWER

The iPhone supports all the normal web technologies for communication. HTTP, SOAP, REST etc are all doable. For pretty much everything network related, I recommend ASIHTTPRequest.

It is powerful, well documented and easy to learn. You can download files, complete pages and even submit data with FORM protocols etc.

If you want to save data to the disk, the iPhone supports SQLite and has it's own technology called Core Data.

Parsing data is dead easy too. For JSON, use YAJL. For XML parsing or HTML scraping, use XPathQuery of TFHpple (TFHpple is a wrapper over XpathQuery that makes it a little easier to get running with).

If you have any other questions, just comment :)

2
Alex Wayne On

The ASI HTTP Request library is pretty awesome:

- (IBAction)grabURL:(id)sender
{
  NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
  ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
  [request startSynchronous];
  NSError *error = [request error];
  if (!error) {
    NSString *response = [request responseString];
  }
}

See: http://allseeing-i.com/ASIHTTPRequest/

Otherwise you get to party with a verbose and painful NSURLConnection: http://developer.apple.com/library/ios/#documentation/cocoa/reference/foundation/Classes/NSURLConnection_Class/Reference/Reference.html

0
picknick On

The trivial way to get data from the web is to use:

NSString *response = [NSString stringWithContentsOfURL:url];

Let's say that the response is a json object I would recommend you checking out this project: http://code.google.com/p/json-framework/

It makes it real easy to parse the response.