The following code generates an inconsistent output. It is supposed to log “testString is nil : (null)”. But it sometimes also logs “testString is : (null)”.
What can caused this or did I miss something?
NSString *testString = nil;
if (!testString)
NSLog(@"testString is nil : %@", testString);
else
NSLog(@"testString is : %@", testString);
Most likely your test string is coming from, eg, a stringWithFormat operation such as
stringWithFormat:@"%@", someObject, and “someObject” is nil.