我正在尝试对一组进行排序,大多数情况下效果很好。但是当我开始在旧的iPhone 5c上使用我的应用程序时,很多对象进入了场景,我最终会遇到这个错误:
EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)
if(manager.allBeacons){
NSSet *beacons = [manager.allBeacons copy];
NSSet *filteredSet = [[NSSet alloc] initWithSet:[beacons filteredSetUsingPredicate:predicate]];
if(filteredSet){
//NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"RSSI" ascending:NO];
//NSArray *sortDescriptors = [NSArray arrayWithObject:descriptor];
//NSArray *sortedArray = [[NSArray alloc] initWithArray:[filteredSet.allObjects sortedArrayUsingDescriptors:sortDescriptors]];
NSArray *sortedArray = [filteredSet.allObjects sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
if([obj1 isKindOfClass:[BLUSBeacon class]] && [obj2 isKindOfClass:[BLUSBeacon class]]){
BLUSBeacon *beacon1 = obj1;
BLUSBeacon *beacon2 = obj2;
if(beacon1.RSSI.integerValue > beacon2.RSSI.integerValue){
return (NSComparisonResult)NSOrderedAscending;
}
if(beacon1.RSSI.integerValue < beacon2.RSSI.integerValue){
return (NSComparisonResult)NSOrderedDescending;
}
}
return (NSComparisonResult)NSOrderedSame;
}];
if(sortedArray){
self.beacons = sortedArray;
[self.tableView reloadData];
}
}
}
这是stacktrace中的最后一步,以防它用于任何目的: