O'Reilly logo

iOS 8 SDK Development, 2nd Edition by Janie Clayton, Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing the Twitter Response

Inside our handleTwitterData method, we receive the raw data from the Twitter API and can use it to update our UI.

We’ll start by handing the raw data over to Foundation’s NSJSONSerialization, which can easily produce either an NSArray or NSDictionary of the parsed data, an object that may itself be a deep structure of nested arrays and/or dictionaries. Let’s do a quick sanity check by replacing the log statement with the following:

Asynchronicity/PragmaticTweets-6-1/PragmaticTweets/ViewController.swift
Line 1 
func​ handleTwitterData (data: NSData!,
urlResponse: NSHTTPURLResponse!,
error: NSError!) {
if​ ​let​ dataValue = data {
var​ parseError : NSError? = nil
let​ jsonObject : AnyObject? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required