首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ACAccountStore accountsWithAccountType返回空列表但授予访问请求

ACAccountStore accountsWithAccountType返回空列表但授予访问请求
EN

Stack Overflow用户
提问于 2015-04-18 18:57:31
回答 1查看 1.5K关注 0票数 3

下面有一段Swift代码可以连接到我的iOS模拟器中的twitter帐户。

我对requestAccessToAccountsWithType的调用被授予,但是ACAccountStore.accountsWithAccountType返回一个空列表。

我遗漏了什么?

代码语言:javascript
复制
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)
    }
}

requestAccessToAccountsWithType for Twitter (com.apple.twitter)被授予accountsWithAccountType返回0

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-19 22:25:40

授予访问权限是一回事,您还需要在设备/模拟器上配置Twitter帐户。检查你是否设立了任何帐户。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29721496

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档