2

I am trying to create a Rest web service running on iPhone; I've done my initial research and found CocoaHttpServer and TouchCode json parser, is there any library / sample code which binds these together into a Rest endpoint?

If it does not exist, how do I go about writing one? Any reference to some kind of design document etc. will really help.

3 Answers 3

7

I'm using CocoaHTTPServer and the iOS builtin JSON libraray to have a RESTful service in iVocabulary. First I wrote a lengthy Connection class (the core for handling requests in CocoaHTTPServer) myself. But parsing the URL was kind of complicated.

So I wrote a more generic Connection class that routes HTTP requests to different blocks for different URLs and different HTTP methods. The URL can contain parameters (with : as prefix), that get parsed. That's not a generic REST service per se, but I added (for example) a block for the url "/rest/:entityname" that fetches all Core Data objects of the given entity.

You can find that router implementation in my fork of CocoaHTTPServer on github: https://github.com/chbeer/CocoaHTTPServer

Another router implementation: https://github.com/mattstevens/RoutingHTTPServer

1
  • My extension works the same. But I added it to my fork of CocoaHTTPServer as an external extension. Jun 23, 2012 at 6:27
-1

Check RestKit for working with Restful web services.

http://restkit.org/

1
  • @nielsbot : exactly , I looked into RestKit, it does not provide any "server" api's, it can only consume..
    – srinathhs
    Apr 7, 2012 at 6:28
-2

I recommend RestKit, I have used for over a year now and love it. However I recently learned about AFNetworking from some colleagues that claim it's very lightweight and thus prefer it as an alternative to RestKit, so I am giving it a try soon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.