我有一个
火车站
对象定义为:
@interface RFStation : NSObject {
NSString *stationID;
NSString *callsign;
NSString *logo;
@end
我还有一个名为'
统计人员
'这是桩号对象的列表。此列表按字母顺序排列'
呼号
'.
我还有另一个NSArray叫'
将军
,包含字母“A”到“Z”
我想创建一个UITableView,其中的节头a-Z对应于每个呼号的第一个字母。
我目前有这些方法&定义的对象:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [generalList count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [generalList objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSPredicate *filter = [NSPredicate predicateWithFormat:@"callsign beginswith[cd] %@",[generalList objectAtIndex:section]];
return [[stationList filteredArrayUsingPredicate:filter] count];
}
当然还有:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
RFStation *aStation = [stationList ObjectAtIndex:[indexPath row]];
static NSString *identity = @"MainCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identity];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0) reuseIdentifier:identity] autorelease];
}
cell.text = aStation.callsign;
return cell;
}
然而,我的标题似乎没有正确地对NSMutableArray数据进行排序。我的代码有什么问题(我怀疑它是谓词)