I am a relatively experienced iOS developer, however one thing has always bothered me, what is the difference between Nil(Capital) and nil(lowercase) and NULL (if any) in terms of performance and usage? I am absolutely sure that there is a difference between them otherwise why would they be defined as separately in the first place...
Asked
Active
Viewed 5,738 times
5
-
1http://stackoverflow.com/a/1564846/1404239 – Lucas Eduardo Sep 01 '13 at 03:03
1 Answers
15
The basic idea is that you use NULL for C pointers (0 for C primitives), nil for Objective C instances, Nil for Objective C classes, and NSNull as a way of pretending that nothing is something so that you can store an instance of nothing in an array or dictionary.
A great description of this and the source of the values listed below can be found at: http://nshipster.com/nil/
NULL (void *)0 literal null value for C pointers
nil (id)0 literal null value for Objective-C objects
Nil (Class)0 literal null value for Objective-C classes
NSNull [NSNull null] singleton object used to represent null

Mick MacCallum
- 129,200
- 40
- 280
- 281