Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I consume a web service in Objective-C?

I have a web service developed in ColdFusion that I am trying to consume on the iPhone. The web service returns JSON which should be fairly simple to read.

However, I have been unable to find a good simple example of an iPhone app calling a web service and using the data. Are there any good tutorials or examples out there that I am just missing?

like image 241
Jason Avatar asked Oct 14 '09 17:10

Jason


2 Answers

A. Get ASIHTTPRequest.

B. Get json-framework.

C. Use A to get data from your web-service then hand it to B which returns a dictionary.

That's pretty much it.

like image 105
Ramin Avatar answered Sep 25 '22 02:09

Ramin


To use JSON, you need to use a 3rd party framework, as there is no built-in support. I suggest using this http://code.google.com/p/json-framework/ as it's one of the simplest to implement. You can make the GET request just using NSURLRequest, or I'd also recommend using http://allseeing-i.com/ASIHTTPRequest/ if you need to make more complex requests, for example using basic authentication.

I wrote a blog post that has step-by-step instructions on using JSON from Cocoa/Objective-C with an example:

http://zachwaugh.com/2009/01/how-to-use-json-in-cocoaobjective-c/

like image 45
Zach Waugh Avatar answered Sep 25 '22 02:09

Zach Waugh