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

Using the Twitter SLAccount

Now let’s fill out the empty else case, replacing the simple success println. We’re going to work with the accountStore that the user has graciously given us permission to use. Because it’s a local variable in scope at the time of the closure’s creation, we can use it within the completion handler closure.

On iOS, the user may have set up several accounts of a given type; a fancier app would show them and let the user pick one, but for now, we’ll just make sure there’s at least one. We can use the ACAccountStore’s accountsWithAccountType to get all configured accounts of type twitterAccountType.

Asynchronicity/PragmaticTweets-6-1/PragmaticTweets/ViewController.swift
 
let​ twitterAccounts = accountStore.accountsWithAccountType(twitterAccountType) ...

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