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.
let twitterAccounts = accountStore.accountsWithAccountType(twitterAccountType) ...