这可行,但是每次都会随机排序。
在点中有一个point.pointOrder,它是一个NSNumber。我想在point.pointOrder之后对它们进行排序。任何人都可以指出;)我朝着正确的方向吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
OIOISingleTourTableViewCell *cell = (OIOISingleTourTableViewCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
point = [[self.tour.tour_infopoint allObjects] objectAtIndex:indexPath.row];
cell.lblInfoPointName.text = point.pointName;
return cell;
}
最佳答案
NSSet
永不排序。您需要使用NSSortDescriptor
对其进行排序
NSArray *infoPointArray = [self.tour.tour_infopoint sortedArrayUsingDescriptors:[NSSortDescriptor sortDescriptorWithKey:@"pointOrder" ascending:YES]];
然后使用
infoPointArray
代替[self.tour.tour_infopoint allObjects]
关于ios - 用实体对TableView排序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23343515/