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

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.