Consuming and Parsing JSON Service in iOS 5 – The Easy Way

Let’s say I want to get tweets from Twitter.

  • I send HTTP request to Twitter with “Accept” header set to “application/json”
  • Receive returned JSON and parse it
  • Do whatever I want with parsed JSON

Above code uses two API provided only in iOS 5 or later:

  • Asynchronous and block-based handler NSURLConnection
  • NSJSONSerialization

You don’t need any third party libraries.