0

オブジェクトを含む配列のコンテンツを表示するtableViewがあります。しかし、テーブルビューには日付ごとのセクションがあり、すべてのセクションで同じコンテンツを取得します。NSDictionary *object = [array objectAtIndex:indexPath.row];配列全体ではなく、セクションの行が返されると思います。tableView全体の行数を取得するにはどうすればよいですか?それとも他の方法ですか?

4

1 に答える 1

1
int rowsOffset = 0;
for (int section; section ++; section < indexPath.section) {
  rowsOffset += [[[titles objectAtIndex:section] objectForKey:@"Values"] count];
}

NSDictionary *object = [array objectAtIndex:indexPath.row+rowOffset];

おそらくより良い:

NSArray *theArray = [[titles objectAtIndex:indexPath.section] objectForKey:@"Values"];
NSDictionary *object = [theArray objectAtIndex:indexPath.row];
于 2012-09-25T13:33:36.577 に答える