Atu*_*tia 6 crash ios crashlytics
我开始在我的iphone应用程序中使用crashlytics,它似乎在启动期间(或者我猜的是启动时)为某些用户崩溃.这是堆栈跟踪:
Fatal Exception: NSInvalidArgumentException
-[NSNull rangeOfCharacterFromSet:]: unrecognized selector sent to instance 0x19687eba0
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x00000001854aa59c __exceptionPreprocess + 132
1 libobjc.A.dylib 0x0000000195bfc0e4 objc_exception_throw + 60
2 CoreFoundation 0x00000001854b1664 __methodDescriptionForSelector
3 CoreFoundation 0x00000001854ae418 ___forwarding___ + 928
4 CoreFoundation 0x00000001853b2b6c _CF_forwarding_prep_0 + 92
5 UIKit 0x0000000189fc38a0 -[UILabel _contentInsetsFromFonts] + 104
6 UIKit 0x000000018a13ac90 -[_UILabelLayer updateContentInsets] + 76
7 UIKit 0x000000018a13ad50 -[_UILabelLayer updateContentLayerSize] + 56
8 UIKit 0x000000018a13ae34 -[_UILabelLayer layoutSublayers] + 36
9 QuartzCore 0x00000001895ac564 CA::Layer::layout_if_needed(CA::Transaction*) + 320
10 QuartzCore 0x00000001895ac408 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
11 QuartzCore 0x00000001895abc08 CA::Context::commit_transaction(CA::Transaction*) + 276
12 QuartzCore 0x00000001895ab98c CA::Transaction::commit() + 436
13 QuartzCore 0x00000001895a53bc CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
14 CoreFoundation 0x0000000185462a50 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
15 CoreFoundation 0x000000018545f9dc __CFRunLoopDoObservers + 360
16 CoreFoundation 0x000000018545fdbc __CFRunLoopRun + 836
17 CoreFoundation 0x000000018538d0a4 CFRunLoopRunSpecific + 396
18 GraphicsServices 0x000000018e52f5a4 GSEventRunModal + 168
19 UIKit 0x0000000189cc23c0 UIApplicationMain + 1488
20 partybutton 0x00000001000d6de0 main (main.m:16)
21 libdyld.dylib 0x000000019626aa08 start + 4
Run Code Online (Sandbox Code Playgroud)
不确定如何调试这个,因为我无法自己重现.有什么指针吗?
kaz*_*mun 15
我有类似的问题.来自服务器的JSON响应包含NULL/null.像这样的东西:
"result":[
{
"id":"44",
"message":null,
}]
Run Code Online (Sandbox Code Playgroud)
我创建了一个NSNull类.然后添加NSString导致异常的方法.
NSNull + JSON.h文件:
#import <UIKit/UIKit.h>
@interface NSNull(JSON)
@end
Run Code Online (Sandbox Code Playgroud)
NSNull + JSON.m文件:
@implementation NSNull (JSON)
- (NSUInteger)length { return 0; }
- (NSInteger)integerValue { return 0; };
- (float)floatValue { return 0; };
- (NSString *)description { return @"0(NSNull)"; }
- (NSArray *)componentsSeparatedByString:(NSString *)separator { return @[]; }
- (id)objectForKey:(id)key { return nil; }
- (BOOL)boolValue { return NO; }
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet{
NSRange nullRange = {NSNotFound, 0};
return nullRange;
}
//add methods of NSString if needed
@end
Run Code Online (Sandbox Code Playgroud)
通过这样做,我不必在每个变量中检查NULL.
| 归档时间: |
|
| 查看次数: |
4662 次 |
| 最近记录: |