0
我是一个排序系统,它对数组中的数据进行排序,尽管我在完成边缘遇到了麻烦。尽管现在告诉我我有一个错误,但我已经设置了所有的系统来完成它。这是有问题的代码段和错误它给:排序UITableView无法正常工作
NSArray *filteredArray = [[patients filterUsingPredicate:search] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
它说的错误是在患者和它说:
Bad receiver type void
这是在上下文中的代码:
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIndentifier = @"cell";
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:cellIndentifier forIndexPath:indexPath];
NSString *letter = [charIndex objectAtIndex:[indexPath section]];
NSPredicate *search = [NSPredicate predicateWithFormat:@"patientName beginswith[cd] %@", letter];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"patientName" ascending:YES];
NSArray *filteredArray = [[patients filterUsingPredicate:search] sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
if (nil == cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
NSLog(@"indexPath.row = %d, patients.count = %d", indexPath.row, patients.count);
Patient *thisPatient = [filteredArray objectAtIndex:[indexPath row]];
cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", thisPatient.patientName, thisPatient.patientSurname];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.textColor = [UIColor blackColor];
if (self.editing) {
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
return cell;
}
是发生了很多事情,如果是的话有一个方法吗?
在此先感谢
我会怎么做,我是很新的Objective-C。对不起 – Hive7
因为你放了不同的代码,我改变了我的答案。 –
谢谢它的工作完美 – Hive7