【发布时间】:2013-02-01 00:37:06
【问题描述】:
我设法创建了Array 的MyLocation 对象,它们的距离属性设置在tabBarController 的2 个选项卡中的第一个。在我的第二个标签中,我在viewDidLoad 中得到它:
[self setAnnotationsToSort:myDelegate.annotationsToSort];
在这一行之后我调用了这个方法:
-(void)sort{
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"distance" ascending:YES] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray;
sortedArray = [self.annotationsToSort sortedArrayUsingDescriptors:sortDescriptors];
[self.tableView reloadData];
}
应该对我的Array 进行排序。但是我的tableView 当前加载了Array、self.annotationsToSort 的未排序版本。如何重新加载 tableView 但强制它使用新的 sortedArray?
【问题讨论】:
标签: ios objective-c nsarray nssortdescriptor