0
Facebook 사용자 데이터가 가입 텍스트 필드 자동 완성을 받고 있습니다.TextField 업데이트에 이상한 지연이 있습니다.
문제점 : 테스트를 수행하고 NSLog가 정보를 빠르게 반환하지만 TextFields.text를 업데이트하는 것이 지연됩니다.
코드 :
- (IBAction)facebookProfile:(id)sender {
if(!_accountStore)
_accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookTypeAccount = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[_accountStore requestAccessToAccountsWithType:facebookTypeAccount
options:@{ACFacebookAppIdKey: @"417425124162461", ACFacebookPermissionsKey: @[@"email"]}
completion:^(BOOL granted, NSError *error) {
if(granted){
NSArray *accounts = [_accountStore accountsWithAccountType:facebookTypeAccount];
_facebookAccount = [accounts lastObject];
NSLog(@"Success");
[self me];
}else{
// ouch
NSLog(@"Fail");
NSLog(@"Error: %@", error);
}
}];
}
- (void)me {
NSURL *meUrl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
SLRequest *meRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:meUrl parameters:nil];
meRequest.account = _facebookAccount;
[meRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (!error) {
NSDictionary *resultsDictionary = [responseData objectFromJSONData];
NSLog(@"%@", [resultsDictionary objectForKey:@"name"]);
// The problem is here. While NSLog runs in seconds showing Facebook User Name, the textfiend.text updates take about 10 seconds longer.
_tfName.text = [resultsDictionary objectForKey:@"name"];
_tfEmail.text = [resultsDictionary objectForKey:@"email"];
_tfGender.text = [resultsDictionary objectForKey:@"gender"];
_tfBirthday.text = [resultsDictionary objectForKey:@"birthday"];
}
}];
}
감사합니다. 약간의 수정, 그것은'});'dispatch_async'를 닫습니다. –
그 작은 오타를 유감스럽게 생각합니다. 감사. – rmaddy
감사합니다. 완벽하게 작동했습니다! ;) –