accountsWithAccountType返回空数组

qua*_*ato 1 ios6 acaccount

iOS6的.我在"设置"应用中登录了Twitter.

我关闭了我的应用程序和设置应用程序然后重新运行.

ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *accountType = [store  accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[self createAccountPickerForAccountType:accountType withStore:store];
Run Code Online (Sandbox Code Playgroud)

...

- (void)createAccountPickerForAccountType:(ACAccountType *)accountType withStore:
self.accounts = [store accountsWithAccountType:accountType];
[self displayAccountPicker];
Run Code Online (Sandbox Code Playgroud)

返回的数组是一个空数组.

Set*_*zer 5

我也在手机上看到了这个,但它在模拟器中有效.

我正在做:

ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *twitterAccountType =
[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[store requestAccessToAccountsWithType:twitterAccountType options:nil^(BOOL granted, NSError *error) {

    NSArray *twitterAccounts =  [store accountsWithAccountType:twitterAccountType];
    int count = [twitterAccounts count];
}];
Run Code Online (Sandbox Code Playgroud)

来自https://dev.twitter.com/docs/ios-frequently-asked-questions

"为什么我的应用程序归类为"来自iOS",而不是来自twitter.com上的"来自"?

如果您的应用程序尚未在App Store中存在:

发出请求的应用程序必须在Apple的App Store中启动,以便在twitter.com上显示该属性.请注意,iOS5版本的应用程序必须是实时的,而不仅仅是以前的版本."

我想知道是否可以,因为我的应用程序不在应用程序商店中了吗?

  • 更新:想通了!在计数生效之前,您必须要求权限(并授予它们).要求权限使用[ACAccountStore requestAccessToAccountsWithType] (7认同)