开发者

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

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

T开发者_JAVA技巧hank you

Cheer Bob


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 :)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜