0

What is the basic difference between Nil, nil, NULL and NSNull in iOS. Is NSNull related to objective C? It would be better if anyone can explain separately in swift and objective C.

Harry J
  • 1,842
  • 3
  • 12
  • 28
  • That [NSHipster link](https://nshipster.com/nil/) that Vipin shared with you pretty much summarizes it. If you’re going through all of the possible “nil” values, you might stumble across in Objective-C, you might throw `kNilOptions` (e.g., https://stackoverflow.com/q/24758086/1271826) in the mix, too. Obviously, life is simpler in Swift. – Rob Feb 10 '20 at 05:27

1 Answers1

0

You can refer this link

Objective-C nothing is nil. nil is an object pointer to nothing.Although semantically distinct from NULL, they are technically equivalent to one another.

On the framework level, Foundation defines NSNull, which defines a class method +null, which defines the singleton NSNull object. NSNull is different from nil or NULL, in that it is an actual object, rather than a zero value.

Foundation/NSObjcCRuntime.h also defines Nil as a class pointer to nothing. This lesser-known title-case cousin of nil doesn’t show up much very often, but it’s at least worth nothing.

Newly alloc’d NSObjects start life off with their contents set to 0. This means that all points that object has to other points bigs as nil.

VipinYadav
  • 808
  • 4
  • 16