What is difference between nil
and Nil
in iOS development?
And similarly what is difference between true
and TRUE
in iOS development?
nil is the literal null value for Objective-C objects, corresponding to the abstract type id or any Objective-C type declared via @interface. For instance:
NSString *someString = nil;
NSURL *someURL = nil;
id someObject = nil;
if (anotherObject == nil) // do something
Nil is the literal null value for Objective-C classes, corresponding to the type Class. Since most code doesn’t need variables to reference classes, its use is not common. One example is:
Class someClass = Nil;
Class anotherClass = [NSString class];
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