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

Making the Twitter Code More General-Purpose

Now that the delegate protocol is declared, we have the pieces in place for our genericized Twitter calls: callers will provide the TwitterAPIRequest with a URL and parameters for their request, and a delegate implementing TwitterAPIRequestDelegate to handle the response. The delegate is often the caller itself.

So, at the top of TwitterAPIRequest.swift, we’ll start by importing the Social and Accounts frameworks, since we’ll be using classes from both of them.

Growing/PragmaticTweets-8-1/PragmaticTweets/TwitterAPIRequest.swift
 
import​ Social
 
import​ Accounts

Now, inside the curly braces of class TwitterAPIRequest: NSObject, here’s how we start declaring our generic Twitter-calling method:

Growing/PragmaticTweets-8-1/PragmaticTweets/TwitterAPIRequest.swift ...

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