我需要使用其內部對象的屬性重新排序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)') –