我正在使用sortedArrayUsingSelector對我有的數組進行排序。sortedArrayUsingSelector caused SIGABRT
下面是我在呼喚它:
NSArray *sortedArray;
SEL sel = @selector(intSortWithNum1:withNum2:withContext:);
sortedArray = [_myObjs sortedArrayUsingSelector:sel];
而這裏的定義是:
- (NSInteger) intSortWithNum1:(id)num1 withNum2:(id)num2 withContext:(void *)context {
CLLocationCoordinate2D c1 = CLLocationCoordinate2DMake([((myObj *)num1) getLat], [((myObj *)num1) getLong]);
CLLocationCoordinate2D c2 = CLLocationCoordinate2DMake([((myObj *)num2) getLat], [((myObj *)num2) getLong]);
NSUInteger v1 = [self distanceFromCurrentLocation:(c1)];
NSUInteger v2 = [self distanceFromCurrentLocation:(c2)];
if (v1 < v2)
return NSOrderedAscending;
else if (v1 > v2)
return NSOrderedDescending;
else
return NSOrderedSame;
}
我得到我的主要的線程1 SIGABRT錯誤,當我跑我的應用程序。
任何想法?提前致謝。
注:我已經嘗試過這樣的:
NSArray *sortedArray = [[NSArray alloc] init];
它並沒有解決任何事情。
你可以添加堆棧跟蹤嗎? * thread1 SIGABRT *不會說太多..(至少對我來說) – rdurand
如何在XCode中獲取堆棧跟蹤? – Inbl
在應用程序崩潰後的控制檯輸出中 – rdurand