I am currently studying objective-c and the basic c programming language.
I have a questions about a particular line of code:
if (!balance)
In Objective-C, nil
is roughly analogous to 0
, NULL
or false
, but for object pointers. In an if
statement, it will behave the same as one of the aforementioned scalar values. For example, the following two if
statements should produce the same results:
NSNumber *balance = nil;
if (!balance) {
// do something if balance is nil
}
if (balance == nil) {
// do something if balance is nil
}