我有一个表视图,它显示来自带有对象的数组的内容。但是表格视图每个日期都有部分,我在所有部分中都获得了相同的内容。我想NSDictionary *object = [array objectAtIndex:indexPath.row];
返回该部分的行,而不是整个数组的行。如何获取整个表视图的行计数?还是其他方法?
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];