I was getting random crashes in my app until I narrowed it down to a particular method. In that method I expect an NSString
as a parameter. This NSString
can sometimes be nil in which case the method ends and no harm is done.
When I run my method's parameter through NSLog(@"%@", myString)
I found that I get one of these:
- The contents of an actual NSString
- (null)
- <null>
The first two are expected and handled by my method. The third one, <null>, crashes my app with -[NSNull length]: unrecognized selector sent to instance 0x1b2ace8
.
I have found a way around the problem by checking for nil
or isKindOfClass
, but my question is what is the difference between (null) and <null>?.