我需要使用其内部对象的属性重新排序NSMutableArray。为一个对象的双重属性排序数组
我在日期以前的项目就是这样做的日期,但这种方法不接受双打:
NSUInteger rowIndex = [self.alist indexOfObject:assignment inSortedRange:NSMakeRange(0, self.alist.count) options:NSBinarySearchingInsertionIndex usingComparator:^(AssignmentInfo *obj1, AssignmentInfo *obj2) {
NSDate *date1 = obj1.dateTime;
NSDate *date2 = obj2.dateTime;
if ([date1 compare:date2] == NSOrderedAscending) {
return NSOrderedAscending;
}
if ([date1 compare:date2] == NSOrderedDescending) {
return NSOrderedDescending;
}
return NSOrderedSame;
}];
因此,没有我需要的方式重新排列阵列self.communitiesArray
为社会目标的双重价值在数组中。 self.community.distanceFromUser
这是双。
使用一些答案下面我就得到一个错误的:
NSUInteger rowIndex = [self.communitiesArray indexOfObject:community inSortedRange:NSMakeRange(0, self.communitiesArray.count) options:NSBinarySearchingInsertionIndex usingComparator:^(Community *obj1, Community *obj2) {
错误说:不相容块指针类型发送 '无效(^)(社区* _ 强,社区* _strong)'以类型的参数 'NSComparator'(又名 'NSComparisonResult(^)(__强大的ID,ID __strong)')
我得到一个错误:'NSUInteger rowIndex = [self.communitiesArray indexOfObject:community inSortedRange:NSMakeRange(0,self.communitiesArray.count)options:NSB错误表示:不兼容的块指针类型将'void(^)(Community * __ strong,Community * __ strong)'发送给'NSComparator'类型的参数(又名' NSComparisonResult(^)(__ strong id,__strong id)') –