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 ...

Get iOS 8 SDK Development, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.