the console prints me (null) for an variable that should not be, so I want to put an assert there just for fun:
NSAssert(myVar, @"myVar was (null)!");
what's the trick here? this (null) thing doesn't seem to be "nil", right? How can I check for it? I want to assume that the var is set properly and not nil, not null.
Assuming myVar is of type id (or any object type), use
NSAssert(myVar != nil, @"")
If the assertion passes, you should be able to print myVar to the console with
NSLog(@"myVar = %@", myVar);
As a side note, nil==null, (both are #defined as __DARWIN_NULL which is #defined ((void *)0)). If you try to use NSLog to print the -description of a nil (or NULL) object reference you get "(null)"
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