Trying Out Our Function

To prove all this refactoring has been worth it, let’s see how much easier it’ll be to add Twitter calls to our existing classes or those we may yet create.

Just for kicks—and with the understanding we’ll undo this silly code in a few minutes when we’re done with it—take a look at AppDelegate.swift. This class has to do with how our app interacts with the rest of the system, something we’ll talk about more later. For now, notice there is a method called applicationWillEnterForeground. This is called when the app is brought back to life from the background. Let’s do a Twitter call every time this happens.

Let’s use a simple Twitter API: users/suggestions. This sends us some suggested topics, based on who we follow. Thanks ...

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