2013-04-20 56 views
2

我正在使用SLRequest發佈到Twitter的應用程序。我已經在模擬器上工作了,但它不適用於我的設備。ACAccountStore返回設備上的空數組,但在模擬器上工作

[self.accountStor accountsWithAccountType:accountTypeTwitter]; 

返回我設備上的空數組,但它在模擬器上顯示正確的帳戶。我不知道爲什麼會發生這種情況。

我有一種方法可以獲取用戶的Twitter帳戶。它看起來像這樣:

- (void)fetchTwitterAccounts 
{ 
    if (self.accountStore == nil) { 
     self.accountStore = [[ACAccountStore alloc] init]; 
    } 

    ACAccountType *accountTypeTwitter = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 
    self.twitterAccounts = [self.accountStore accountsWithAccountType:accountTypeTwitter]; 
    [self.tableView reloadData]; 
} 

爲什麼我沒有在我的設備上獲得任何帳戶的任何想法?

回答

3

您有Twitter帳戶,並且該應用有權在您的設備上使用它們?在嘗試獲取帳戶列表之前,您是否調用requestAccessToAccountsWithType

檢查下面如何帳戶列表時,首先請求訪問檢索且僅當用戶檢索帳戶

https://dev.twitter.com/docs/ios/making-api-requests-slrequest的列表(特別是線32-42)授予的例子。

+0

謝謝,讓它工作。 – Anders 2013-04-21 10:57:21

相關問題