I have run into some weird behavior on iPhone 6, iOS 8.3.
appVersion is an NSString* parameter being passed in.
NSLog(@"A:%@:%d",appVersion,(int)appVersion.length);
if (!appVersion)
NSLog(@"a");
if (appVersion == 0)
NSLog(@"b");
if (appVersion == nil)
NSLog(@"c");
if (appVersion == NULL)
NSLog(@"d");
if (appVersion == Nil)
NSLog(@"e");
if ([appVersion isEqual:[NSNull null]])
NSLog(@"f");
NSString* av = [NSString stringWithFormat:@"%@",appVersion];
if ([av isEqualToString:@"(null)"])
NSLog(@"g");
if (((int)appVersion) == 0)
NSLog(@"h");
if (appVersion) {
NSLog(@"B:%@:%d",appVersion,(int)appVersion);
params[@"appversion"] = appVersion;
}
The release build of the app returns:
A:(null):0
g
h
B:(null):0
and then crashes ('object cannot be nil (key: appversion)').
The debug build returns:
a
b
c
d
e
g
h
What is nil, but not nil?