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

Wrap-Up

Because of the complexity of closures and asynchronous code, let’s take a break here and assess what we’ve done.

We want to get at the raw Twitter data, so we ask for access to the user’s accounts and wait for that to happen (since they might be blocked on an Allow / Don’t Allow alert). If we are allowed to use the Twitter account, we send off a request, wait for that to come back, and then use NSJSONSerialization to turn the received NSData into an array of dictionaries, one entry per tweet. Both of the waiting parts are done with closures, telling the iOS frameworks what work we want them to do once they’re able.

We’ve written two closures, both using the “completion handler” pattern that is common in iOS. In the next chapter, we’re ...

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