I thought that when I declare an object the pointer is still nil until when I allocate memory and initialize it. Instead I run this code and I was surprised to see that it outputs “TRUE”:
NSString * aString;
if (aString) {
NSLog(@"TRUE");
}
thanks
It is pointing at an undefined location – it can point to any memory location (even one that you don’t have access to.
You should
NILit out when declaring it.