0

グループ化された UITableView (2 行、最初の行にデータ) があり、Facebook からのデータを入力しようとしていますが、何らかの理由で苦労しています。NSDictionary を入力しようとすると、(私の知る限り) すべてが適切にセットアップされているにもかかわらず、「認識されないセレクター」でクラッシュします。

@property (nonatomic, strong) NSDictionary *album; 
@property (nonatomic, strong) NSArray *fbArray; 
@property (nonatomic, strong) NSArray *album_amount;



-(void)viewDidLoad 
{ 
  [super viewDidLoad]; 
  self.tableView.delegate = self; 
  self.tableview.dataSource = self; 

  [self requestAlbums]; // Here, I request the user's albums from FB
}

- (void)requestAlbums 
{
[FBRequestConnection startWithGraphPath:@"/me/albums/"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
                          TBAppDelegate *delegate = (TBAppDelegate *)[[UIApplication sharedApplication] delegate];

                          managedObjectContext = [delegate managedObjectContext];

                          if(error)
                          {
                              return;
                          }

                          NSArray* collection = (NSArray*)[result data];

                          self.album = [collection objectAtIndex:0];

                          self.album_amount = collection;

    for (int i=0; i  < self.album_amount.count; i++)
    {
        self.album = [self.album_amount objectAtIndex:i];
        self.photoFQL = [NSString stringWithFormat:@"%@/photos", [self.album objectForKey:@"id"]];

        [FBRequestConnection startWithGraphPath:self.photoFQL completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
         {
         }];

        self.fbArray = [self.album objectForKey:@"name"];

                }


                      }];       
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
NSString *identifier = [NSString stringWithFormat:@"Cell%d", indexPath.row + 1];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];

if (cell.tag == 0)
{        
    NSDictionary *albumDict = [self.fbArray objectAtIndex:indexPath.section]; // Here's where the error is thrown, and I don't know why. I've gone through tutorials, and they either tell me to use indexPath.section or indexPath.row (I have to use indexPath.section as I am using a grouped tableview, right)? 

    NSLog(@"%@", [albumDict objectForKey:@"name"]);

}

if (cell.tag == 1)
{
}

return cell;
}
4

1 に答える 1

0

単なるIDであるため、結果オブジェクトが何であるかはわかりません。

ログアウトしますが。

NSLog (@"result class: %@", NSStringFromClass([result class]));

文字列または NSData の場合は、JSON で解析する必要があります。NSDictionary の場合は、キーを使用してデータにアクセスする必要があります。

于 2013-10-21T00:32:09.387 に答える