【发布时间】:2011-03-27 02:02:34
【问题描述】:
我有一个数组和一个从数组中获取数据的表视图。当我在 iPhone 上查看 tableview 时,它的 ofc 未排序,并且按照我编写的方式列出。
我想在 tableview 中对我的数组进行排序,所以它们不会像这样列出:
- D
- 一个
- G
- F
- S
但改为这样列出:
- 一个
- B
- C
- D
- E
- 等等……
我该怎么做?
这是我的数组:
stationList = [[NSMutableArray alloc] init];
[stationList addObject:@"A"];
[stationList addObject:@"B"];
[stationList addObject:@"C"];
如何将数组加载到我的 tableview 数组中? 加载数组:
NSString *cellValue = [stationList objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
【问题讨论】:
-
阅读 NSMutableArray 的 API 文档 - 有排序方法。或 Google 搜索“排序 nsmutablearray”。
标签: iphone arrays ios uitableview sorting