views:

13036

answers:

8
+8  Q: 

iPhone REST client

Does anybody know is there any good library for iPhone SDK to call REST web service. I want to have something simple like Heroku rest client

A: 

Using REST based services really doesn't need a "good library."

NSURLConnection and NSURLRequest, included in the SDK, are all you really need.

August
You can certainly achieve what you want using the basic libraries in the framework but that doesn't mean a simple, high-level APIs should be discounted.
Luke Redpath
August, I completely disagree. There's a lot of code you have to write in between the NSURL stuff and the REST abstraction. (NSURLConnection doesn't even accumulate bytes in a buffer as they come in off the wire; so there's boilerplate code you have to write every time you use it, and that's just for starters.)
jasoncrawford
+5  A: 

Hope Andrian Kosmaczewski's work can save your time from reinventing the wheels:

http://github.com/akosma/iphonerestwrapper/tree/master

And, it's Public Domain.

digdog
+3  A: 

In case your REST service is implemented in Ruby on Rails, the open source ObjectiveResource project is looking very promising. It has been working great for me in a relatively complex project of mine, and I've even contributed some code back to them.

ObjectiveResource

Adam Alexander
The problem with ObjectiveResource is the lack of asynchronous connection support, which basically means freezing your UI thread every time you call your REST service. Which is unacceptable IMHO. I would stay away from it.
Adrian Kosmaczewski
Please note ObjectiveResource has lightweight asynchronous connection support in the 1.1 branch provided by the ConnectionManager class: http://github.com/yfactorial/objectiveresource/blob/1.1/Classes/lib/ConnectionManager.m
Adam Alexander
+12  A: 

I suggest using the excellent ASIHTTPRequest source from All-Seeing Interactive: http://allseeing-i.com/ASIHTTPRequest. I'm doing this, and so are several released iPhone apps, so you can be sure the code is pretty solid.

This is a wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier. It is written in Objective-C and works in both Mac OS X and iPhone applications.

It is suitable for performing basic HTTP requests and interacting with REST-based services (GET / POST / PUT / DELETE). The ASIFormDataRequest subclass makes it easy to submit POST data and files using multipart/form-data.

Jane Sales
+2  A: 

Thx everybody for help.

My server side is on Rails so looks like ObjectiveResource feet best of my needs.

Aler
+1  A: 

I created a blog article about doing this.

http://www.dreamfreeze.net/weblog/restful%5Fwebservices.html

Logan Cautrell
A: 

ASIHTTPRequest looks really promising to me as an NOOB iPhone developer but has anyone got an example project that uses it that I can look at? Something like the Andrian Kosmaczewski wrapper?

Lee Probert
A: 

[akosma / iphonerestwrappert] try this wrapper from github

Caged / httpriot this is a very Simple HTTP Rest Library for iPhone and Cocoa projects.

yasirmturk