3

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 を返します

4

1 に答える 1

6

アクセスを許可することは 1 つのことですが、デバイス/シミュレーターで Twitter アカウントを構成する必要もあります。アカウントが設定されているかどうかを確認します。

于 2015-04-19T22:25:40.493 に答える