mar*_*oko 1 objective-c nsarray nssortdescriptor ios
我设法创建Array的MyLocation与在第2个选项卡设置的距离属性的对象tabBarController.在我的第二个标签中,我得到它viewDidLoad:
[self setAnnotationsToSort:myDelegate.annotationsToSort];
Run Code Online (Sandbox Code Playgroud)
在这一行之后我称这种方法:
-(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];
}
Run Code Online (Sandbox Code Playgroud)
这应该排序我的Array.但是我tableView目前加载了未分类的版本Array,self.annotationsToSort.我如何重新加载tableView但强制它使用新的sortedArray?
你没有做任何事情sortedArray.尝试
self.annotationsToSort = [self.annotationsToSort sortedArrayUsingDescriptors:sortDescriptors];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
177 次 |
| 最近记录: |