O'Reilly logo

iOS 9 SDK Development 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

Making the Twitter Code More General Purpose

When we’re ready to write these other view controllers to show tweet details and user information, we’re going to need to make new calls to the Twitter API. And considering all the work we did to get our first call working—talking to the ACAccountStore and getting an account and using it to make a request and so on—we really don’t want to repeat all that, right? But right now, that code is all in RootViewController. To make it more general purpose, we’re going to need to extract it, and then generalize it.

To do this, let’s think about how to make a more generic Twitter API caller. The current reloadTweets method uses the ACAccountStore to construct an SLRequest, then calls its performRequestWithHandler ...

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