2011-11-23 2 views
0

몇 주 전에 IOS와 Graph API를 사용하기 시작했습니다. 나는 페이스 북에서 검색하는 앨범 데이터로 UITableView를 채우는 데 문제가있다. 내 appdelegete 내 uitabledatasource하고 나는 사용자가 로그인 한 후 다음과 같은 요청하게 너무 uitabledelegate :Facebook 앨범으로 UITableView 채우기 | IOS

NSString* fql = [NSString stringWithString:@"select object_id, cover_object_id, name, description from album where can_upload=1 and owner=me()"]; 
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"]; 
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self]; 
[theTable reloadData]; 

을 그리고 나는 테이블에 다음과 같은 구현 :

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [self.resultData count]; 
} 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease]; 
    } 
    NSUInteger row = [indexPath row]; cell.textLabel.text = [[self.resultData objectAtIndex:row] valueForKey:@"name"]; 
    NSLog(@"the name %@", [[self.resultData objectAtIndex:row] valueForKey:@"name"]); 
    return cell; 
} 

그리고이 같은 결과를 관리를 :

- (void)request:(FBRequest *)request didLoad:(id)result { 
    if ([result isKindOfClass:[NSArray class]]) { 
     resultData=result; 
     [theTable reloadData]; 
} 
NSLog(@"Result of API call: %@", result); 
} 

나는 쿼리의 정확한 결과를 얻을 수 있지만, 항상 빈

그래서 테이블 데이터를 다시로드하지

답변

1

우선, request:didLoad:resultData을 유지해야합니다 (설정 메소드를 사용하십시오!).

둘째, 테이블에서 데이터를 전혀 다시로드하지 않거나 테이블보기 데이터 소스 방법의 항목이 잘못되어 있는지 확인해야합니다. 전자의 경우 theTable이 실제로 nil이고 request:didLoad: 인 경우 reloadData 호출이 영향을 미치지 않습니다. 디버거로 확인하십시오.

그렇지 않은 경우 자세한 정보가 필요합니다. 디버거를 사용하여 코드를 살펴보고 각 테이블 뷰 데이터 소스 메소드가 호출되고 해당 플로우에서 처리가 잘못되는 경우를 확인하십시오.