Ios UITableView标题的节数未定义

Ios UITableView标题的节数未定义,ios,uitableview,ios6,switch-statement,Ios,Uitableview,Ios6,Switch Statement,如果我有一个UITableView,它有[arrayofStudents count]部分: -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [arrayofStudents count] } 然后我想为每个部分创建一个标题标题(注意,部分的数量与arrayofStudent的大小相关) case语句的数量与arrayofStudents的计数有关,如果我在arrayofStudents

如果我有一个UITableView,它有
[arrayofStudents count]
部分:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [arrayofStudents count]
}
然后我想为每个部分创建一个标题标题(注意,部分的数量与arrayofStudent的大小相关)

case语句的数量与arrayofStudents的计数有关,如果我在arrayofStudents中有10个元素,那么我将有10个部分。 如何在switch case语句中构建它


感谢您的帮助。

案例陈述看起来有些多余:因为节和
NSArray
s都是从零开始索引的,所以使用

return [arrayofStudents objectAtIndex:section];
可能需要在开始时进行一些额外的参数检查来处理默认值。

使用以下方法:

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
            return [arrayofStudents objectAtIndex:section];

}
希望对您有所帮助

您可以使用

[arrayofStudents objectAtIndex:section];

希望这能对您有所帮助。

太简单了,以至于我没有考虑过:/公平地说,我在第一个(正确的)答案上做了标记,即使您的答案更清楚。对不起,伙计,没问题。但如果你看到答案的时间,那么我会在Divz之前回答。@Andronienn thanx接受:)
[arrayofStudents objectAtIndex:section];