gpt4 book ai didi

twrequest - requestAccessToAccountsWithType 在 ios6.1 中已被弃用,我应该使用什么来代替?

转载 作者:行者123 更新时间:2023-12-02 07:02:14 25 4
gpt4 key购买 nike

-(void)getTwittersFollowers{ ACAccountStore *store=[[ACAccountStore alloc]init]; ACAccountType *twitterAccType=[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

**[store requestAccessToAccountsWithType:twitterAccType withCompletionHandler:^(BOOL granted,NSError *error)**{
if(!granted){
NSLog(@"User refused to access to his account");
}else{

NSArray *twitterAcc=[store accountsWithAccountType:twitterAccType];

if([twitterAcc count]>0){
ACAccount *account=[twitterAcc objectAtIndex:0];
NSLog(@"account name %@",[account accountDescription]);

NSMutableDictionary *params=[[NSMutableDictionary alloc]init];
[params setObject:@"1" forKey:@"inclue_entitles"];

NSURL *url=[NSURL URLWithString:@"http://api.twitter.com/1/followers.json"];
//TWRequest *request=[[TWRequest alloc]initWithURL:url parameters:params requestMethod:TWRequestMethodGET];
SLRequest *request=[SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:url parameters:params];
[request setAccount:account];
[request performRequestWithHandler:^(NSData *responce,NSHTTPURLResponse *urlResponce,NSError *error){
if(!responce){
NSLog(@"%@",error);
}else{
NSError *jsonError;
NSMutableDictionary *followers=[NSJSONSerialization JSONObjectWithData:responce options:NSJSONReadingMutableLeaves error:&error];

if(followers!=nil){
for (int i=0; i<[[followers objectForKey:@"users"] count]; i++) {
NSLog(@"_____%@",[[[followers objectForKey:@"users"] objectAtIndex:i] objectForKey:@"screen_name"]);
NSLog(@"______________________________________%@",[[[followers objectForKey:@"users"] objectAtIndex:i] objectForKey:@"profile_image_url"]);


[nameArray addObject:[[[followers objectForKey:@"users"] objectAtIndex:i] objectForKey:@"screen_name"]];


NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[[followers objectForKey:@"users"] objectAtIndex:i] objectForKey:@"profile_image_url"]]];


[imageArray addObject:imageData];

NSLog(@"%i", [imageArray count]);
}

}else{
NSLog(@"%@",jsonError);
}


}
}];
}
}


}];

我应该使用什么来代替突出显示的代码...?

最佳答案

尽管由于某些原因未在文档中明确提及,该方法的替代方法是 - (void)requestAccessToAccountsWithType:(ACAccountType *)accountType options:(NSDictionary *)options completion:(ACAccountStoreRequestAccessCompletionHandler)completion(可以通过查看文档轻松找到)

关于twrequest - requestAccessToAccountsWithType 在 ios6.1 中已被弃用,我应该使用什么来代替?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18502648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com