NSDate *now = [NSDate date];
NSLog(@"This NSDate object lives at %p", now);
NSLog(@"The date is %@", now);
Ok, from this code, I know that now
is a pointer to an NSDate
object, but on the code at line 3, how can you dereference a pointer without an asterisk? Why don't we do code like this on the 3rd line:
NSLog(@"The date is %@", *now);
The %@
format specifier takes a pointer to an object, so there's no need to dereference the pointer in the parameter list. In general, there's no need to dereference pointers to Objective C objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With