0
我有其中的每一个Stop
对象的数组包含按距离排序的Objective-C
@property (nonatomic)CLLocationDistance distanceFromUser;
我怎么能枚举虽然阵列和排序他们最接近最远?这是我尝试过的代码,我没有得到一个排序数组。
NSSortDescriptor * ascendingDistance = [[NSSortDescriptor alloc] initWithKey:@"distanceFromUser" ascending:YES];
[_sortedStops sortedArrayUsingDescriptors:@[ascendingDistance]];
我将不得不使用一个“老派”的排序方法来做到这一点或没有对象 - 有一个功能,我可以用它来轻松地做到这一点?
或使用'sortUsingDescriptors'作为可变数组 –