iOSシミュレーターでTwitterアカウントに接続するための次のSwiftコードがあります。
への呼び出しrequestAccessToAccountsWithType
は許可されACAccountStore.accountsWithAccountType
ますが、空のリストが返されます。
私は何が欠けていますか?
let accountStore = ACAccountStore()
let twitterAccountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)
accountStore.requestAccessToAccountsWithType(twitterAccountType, options: nil) { (granted, error) in
if granted {
print("requestAccessToAccountsWithType for \(twitterAccountType) is granted\n")
let accounts = accountStore.accountsWithAccountType(twitterAccountType)
print("accountsWithAccountType returns \(accounts.count) ")
} else {
let error = "Access to Twitter was not granted."
self.log(error)
handler(error)
}
}
Twitter の requestAccessToAccountsWithType (com.apple.twitter) が付与されている accountsWithAccountType は 0 を返します