简体   繁体   English

NSRangeException,但是在哪里?

[英]NSRangeException, but where?

I have an app, which users are reporting to crash at random times. 我有一个应用,用户报告该应用随机崩溃。 All crashes have the same stack 所有崩溃都具有相同的堆栈

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

This may look fine, but when I look at level 3, 8 and 9, the code makes no sense anymore. 看起来不错,但是当我看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];

The error is a NSRangeException 错误是NSRangeException

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

Can anyone tell me what's going on here? 谁能告诉我这是怎么回事?

Search your source for usage of the selector substringToIndex: . 在您的源中搜索选择器substringToIndex:用法。 I'm not familiar with the AdvancedPriceViewController class; 我对AdvancedPriceViewController类不熟悉; if it's yours, you'll probably find a substringToIndex: in [AdvancedPriceViewController newAP:] where you've constructed an NSRange object with -1 . 如果是您的话,您可能会在[AdvancedPriceViewController newAP:]中找到一个substringToIndex: [AdvancedPriceViewController newAP:]其中已使用-1构造了一个NSRange对象。 When -1 is converted to a uint32 , it'll appear as 2147483647 or MAX_INT . -1转换为uint32 ,它将显示为2147483647MAX_INT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM