22

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


Thx everybody for help.

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

casperOne
  • 73,706
  • 19
  • 184
  • 253
Aler
  • 15,097
  • 6
  • 23
  • 26

9 Answers9

28

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
  • 13,526
  • 3
  • 52
  • 57
  • Aside from this answer having high upvotes, check out ASI's wall of released apps that use their framework: http://allseeing-i.com/ASIHTTPRequest/Who-is-using-it I just started using it today and it's pretty easy w/ good docs, lotsa features, and minimal coding out of the box. /plug – jinglesthula Jun 28 '11 at 04:54
  • @Blake - btw, I know just because something's popular doesn't mean it's always the best solution. I'll have to check out restkit. – jinglesthula Jun 28 '11 at 04:56
5

Take a look at RestKit: http://restkit.org/ It provides an excellent API for accessing RESTful web services and representing the remote resources as local objects, including persisting them to Core Data. It's fully asynchronous and sports a lot of other slick features

Blake Watters
  • 6,607
  • 1
  • 43
  • 33
  • This was what I tried this week when I had this need, but for what it's worth, it's not proved a good solution for me. It's very much "heavy" and hard to even get up and running -- I've spent about four hours on it now, and it still won't compile (using the latest XCode on 10.7.2). Clearly some people have gotten it to work, and perhaps once you get over the initial hurdle it's fine, but for me it's just not worth it -- I want something that's a handful of source files I can drop into my project and be done with it. – Joe Strout Feb 03 '12 at 16:41
5

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
  • 4,198
  • 1
  • 26
  • 23
4

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
  • 15,132
  • 5
  • 42
  • 41
  • 2
    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 Jan 04 '10 at 08:40
  • 1
    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 Jan 04 '10 at 18:33
2

I created a blog article about doing this.

http://www.dreamfreeze.net/weblog/restful_webservices.html

0

[akosma / iphonerestwrappert] try this wrapper from github

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

yasirmturk
  • 1,924
  • 2
  • 22
  • 32
0

After using the super verbose and painful delegates that you had to until iOS 4, we moved over to using blocks for asynchronous behavior. it's been really great and has allowed our code to actually be readable lately.

We open sourced the rest client that we used here :

https://github.com/jeremylightsmith/RestClient

Let us know how it works for you.

Jeremy Lightsmith
  • 256
  • 1
  • 3
  • 8
0

You can check your server response with a rest client app on iphone - http://itunes.apple.com/us/app/rest-client/id503860664?ls=1&mt=8

This can help you debug your code on server side.

Rajat Talwar
  • 11,922
  • 1
  • 18
  • 12
-1

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

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

August
  • 12,139
  • 3
  • 29
  • 30
  • 1
    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 Nov 29 '09 at 00:08
  • 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 Feb 05 '10 at 03:54
  • 2
    One of the real benefits of using a decent high-level library is keeping all of the high-ceremony boilerplate code out of your main app logic. NSURL and NSURLConnection can be cumbersome and once you start looking toward production, you will need to keep parsing and such off of the main thread for performance. Good frameworks simplify these common tasks. – Blake Watters Feb 24 '11 at 13:08