Я создал простой менеджер Twitter, который работает как модель.
Для этой модели я добавил свойство «account» для хранения 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 соответствовать запросу учетной записи.