RestKit is an Objective-C framework for iOS that aims to make interacting with RESTful web services simple, fast and fun.

To start off, I'd like to emphasise the word aims in that sentence. I added RestKit to a project I'm working on which is all about STV (Single Transferrable Vote) elections and the algorithms behind the various types. Naturally, the language I'm using to power the backend is PHP as that comes easiest to me with a front-end interface and an iOS application to browse elections, candidates and submit ballots. So all I need was a simple, quick-to-learn framework to let me connect with my API and use the data.

What does RestKit provide?

RestKit's main goal is to allow us, the developers, to think more in terms of our applications data model and worry less about the specific details involding in sending requests, parsing responses and building representations of remote resources.

It provides:

  • A simple, high level HTTP request and response system which gives you a large library of helper methods to inspect and validate MIME types, status codes, submit data (or objects) to an API and, even convert a dictionary of parameters into your HTTP body (now.. that's a bit touchy, see below)
  • Framework integrated support for switching servers and environments which is very handy if you have a distributed cluster of servers as RestKit lets you switch target servers
  • Core Data support which gives you direct object mapping and handles persistence of objects directly to a local store from a remotely loaded location. It also handles associations and relationships which allows you natural property based traversal of your data model.
  • Object mapping system to convert loaded data directly into NSObject's so you don't have to worry about parsing the data you retrieve. All the data you want to map is specified in a key-value coding and RestKit will use reflection to handle the data types.

Is RestKit the-one for my project?

Well, had I known it was would take that long to find the documentation to send a POST request which has the correct parameters from an NSDictionary, I'd of opted for a different framework; however, overall, I think RestKit is an easy to use solution that definitely points you in the right direction. It can make things seem a bit messy and take you some time to get your head around the concepts of NSManagedObject using Core Data and just a plain simple NSObject. 

I think over the 3 or 4 months now I've been developing it, I've picked up the jist of what it is able to do. However, I've probably spent 75% of that time debugging my code to find out how to fix the most common error of "valueForUndefinedKey". However, once you realise what you've done wrong (or in some cases, not what you've done wrong, but what it is trying to map your data to) you can actually get some productivity out of it.

So it is completely up to you if you've got the time and dedication to learn the API and various methods available to be able to take full advantage of what RestKit offers. Their latest version #0.20.0-RC1 and you can download it from the RestKit website.

I'll be looking more in-depth over the most important areas of RestKit over the coming weeks, so stay tuned.

Have you used RestKit? What are your opinions on it? Let me know by mentioning #ALJTMedia on Twitter or leave a comment on our Facebook or Google+ page.

0
Ignite your brand, utilise user-generated content no matter where you or your audience are ›