Two parts of this question
1) Is this an understanding of what is going on right?
"if (obj)" checks if the pointer 0x0 is specified, aka set to the integer memory address
"if (obj! = nil)" compares the memory address of the object with the memory address of the universal object nil
2) Therefore, in a situation where I do not know if a variable is pointing to something, and if so, I also do not know whether this object is a valid object or zero. I want to do many things based on this information, and not just pass on the obj message, which, as I understand it, would be safe if it were null. Is this code correct and necessary?
if (obj && obj != nil) {
[obj someMessage];
[anotherObj someOtherMessage];
}
Thanks guys!
Dougw source
share