NSRangeException,但在哪里?

时间:2014-10-20 12:06:25

标签: ios crash ios8 stack-trace nsrangeexception

我有一个应用,用户报告随机时间崩溃。所有崩溃都有相同的堆栈

0   CoreFoundation  TAGPBIvarClearUInt32 (in SPONTAN) + 11  
1   libobjc.A.dylib _mh_execute_header (in SPONTAN) + 15567 
2   CoreFoundation  TAGPBIvarClearSFixed64 (in SPONTAN) + 13    
3   Foundation  -[AdvancedPriceViewController newAP:] (in SPONTAN) (AdvancedPriceViewController.m:68) + 110325  
4   SPONTAN +[TrStart isJSONTrStart:] (in SPONTAN) + 77 
5   SPONTAN __65-[MintRequestWorker processPreviousLoggedRequestsAsyncWithBlock:]_block_invoke_2 (in SPONTAN) + 397 
6   SPONTAN __58-[FileRepository readLoggedExceptionsWithCompletionBlock:]_block_invoke (in SPONTAN) + 281  
7   libdispatch.dylib   _mh_execute_header (in SPONTAN) + 6195  
8   libdispatch.dylib   -[FirstViewController viewDidLoad] (in SPONTAN) (FirstViewController.m:56) + 84257  
9   libdispatch.dylib   -[FirstViewController viewDidAppear:] (in SPONTAN) (FirstViewController.m:80) + 84769   
10  libsystem_pthread.dylib _mh_execute_header (in SPONTAN) + 3027  
11  libsystem_pthread.dylib _mh_execute_header (in SPONTAN) + 2712

这可能看起来不错,但是当我查看3级,8级和9级时,代码就没有意义了。

3   Foundation  -[AdvancedPriceViewController newAP:] (in SPONTAN) (AdvancedPriceViewController.m:68) + 110325  
Line 68: NSMutableArray *arrayOfIndexPaths = [[NSMutableArray alloc] init];

8   libdispatch.dylib   -[FirstViewController viewDidLoad] (in SPONTAN) (FirstViewController.m:56) + 84257  
Line 56: [[SelectCity titleLabel] setFont:[UIFont fontWithName:@"Avenir" size:15]];

9   libdispatch.dylib   -[FirstViewController viewDidAppear:] (in SPONTAN) (FirstViewController.m:80) + 84769   
Line 80: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

错误是NSRangeException

*** -[__NSCFConstantString substringToIndex:]: Index 2147483647 out of bounds; string length 0

谁能告诉我这里发生了什么?

1 个答案:

答案 0 :(得分:0)

在源代码中搜索选择器substringToIndex:的使用情况。我不熟悉AdvancedPriceViewController课程;如果是您的,那么您可能会在substringToIndex:中找到[AdvancedPriceViewController newAP:],其中您已NSRange-1对象-1。将uint32转换为2147483647时,它会显示为MAX_INT或{{1}}。