English explanation for "nil"!?

whitesaint

cocoa love
okay one of the most used keywords in Objective-C, and probably the least documented, is "nil." Can anyone explain to me in more detail what this means? I read in Apple's Objective-C book that it means "a value of 0"

So would this -

float myFloat = 0

equal the same as saying this -

float myFloat = nil

? Any thoughts? As always take care of yourselves, and eachother.
 
nil is the same thing as null if you've run into that before.

it is valid to say myfloat = nil to set it to zero, but nil is intended more as a sentinal value for object pointers.

Like a NSString* value is actually a pointer to the object, so when you say "myString =nil", you're setting the address you're pointing to to 0. The importance of that is just to have a recognized value meaning, "this object pointer isn't pointing to an object yet". Whereas if myString has a value != nil, then that can tell you that the string has been initialized and should exist.
 
Hey thank you. I still don't know what NULL means. But yea thank you. That was the best explanation ever. And the"this object pointer isn't pointing to an object yet" makes absolutely perfect sense! Now that I have a much better grasp of what "nil" means, I feel awesome. God bless you.

-whitesaint
 
Back
Top