I started using crashlytics for my iphone app, and it seems that it crashes for some users during startup (or what I am guessing is startup). Here is the stack trace:
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
Not really sure how to debug this since I cannot reproduce on my own. Any pointers?
I have similar kind of problem. JSON response from sever contains NULL/null. Something like this:
"result":[
{
"id":"44",
"message":null,
}]
I created a category of NSNull
class. Then added the methods of NSString
that causing the exceptions.
NSNull+JSON.h file:
#import <UIKit/UIKit.h>
@interface NSNull(JSON)
@end
NSNull+JSON.m file:
@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
By doing this I do not have to check NULL in every variable.
For my case,it is JSON data reseponed from service contain NULL String,and Json parsing treat it as string,but the iOS system doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With