【问题标题】:Must every Twitter API request live in an ACAccount request?每个 Twitter API 请求都必须存在于 ACAccount 请求中吗?
【发布时间】:2011-12-11 17:44:18
【问题描述】:

我创建了一个简单的 Twitter 管理器,用作模型。 对于这个模型,我添加了一个属性“帐户”来存储 ACAccount ......现在,如果我尝试像此处显示的代码一样启动 Api 请求,我会得到一个EXC_BAD_ACCESS

-(void)requestFollowers{    
    // Build a twitter request
    TWRequest *followersRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:URL_FOLLOWERS] 
                                                      parameters:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:self.account.username,@"-1",nil] 
                                                                                             forKeys:[NSArray arrayWithObjects:@"screen_name",@"cursor",nil]] requestMethod:TWRequestMethodGET];

    [followersRequest setAccount:self.account];

    [followersRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) 
     {
         //DO SOMETHING

     }];
}

虽然每当我在帐户请求中启动相同的方法时,它都会起作用...

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
    if(granted){
        NSArray *arrayOfAccounts = [accountStore accountsWithAccountType:accountType];

        if ([arrayOfAccounts count] > 0) 
        {   
            self.account = [arrayOfAccounts objectAtIndex:0]; 
             //HERE I LAUNCH PREVIOUS SHOWED METHOD
            [self requestFollowers];                
        }
    }
}];  

因此,我在问是否每个 API 请求都必须包含在帐户请求中。

【问题讨论】:

    标签: ios5 twitter


    【解决方案1】:

    我通过简单地将 ACAccountStore 保留在实例变量中解决了我的 TWRequest 的类似问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-19
      • 2014-10-29
      • 1970-01-01
      • 2011-12-22
      • 2022-01-09
      • 1970-01-01
      • 2014-11-30
      • 1970-01-01
      相关资源
      最近更新 更多