What is the numeric value in the default description of a UIViewController? I had expected it to be the instance address, or perhaps the hash, but when I tested this theory this is what I got:
NSLog(@"Self [%@]", self);
NSLog(@"Address [%p]", &self);
NSLog(@"Hash [%d]", [self hash]);
2012-09-26 10:28:00.202 QuickList7[85957:c07] Self [<SelectCategoryViewController: 0xa42fc60>]
2012-09-26 10:28:00.202 QuickList7[85957:c07] Address [0xbfffdea8]
2012-09-26 10:28:00.203 QuickList7[85957:c07] Hash [172162144]
I haven’t been able to find an explanation in the reference for UIViewController or it’s superclasses – anyone know?
That is indeed the instance address, as for any other
descriptionimplementations that use theNSOBject‘s default implementation.But the instance address is already in the
selfvariable, asselfis of typeUIViewController*and is already a pointer. Printing the pointer value of&selfas you do in your example prints the address of the pointer (pointer to a pointer), not the address of the instance, as&selfis indeed of typeUIViewController**.If you use
NSLog(@"%p", self)instead ofNSLog(@"%p", &self)you will see the same address printed as the one used bydescriptionand displayed withNSLog(@"%@", self).