%@
takes a pointer to an object and sends it the description
message, which returns an NSString
pointer. (You can override description
in your classes to customize the string.)
Added in response to comment:
In Objective-C, you to send messages to objects via a pointer using the [ objectPointer message ]
syntax. So, using your NSDate
example, you can do:
NSDate * now = [NSDate date];
NSString * dateDescription = [now description]; // Note that "now" points to an object and this line sends it the "description" message
NSLog(dateDescription);
Any instance of a class that inherits from NSObject can be sent the description
message and thus a pointer to it can be passed to an %@
format parameter.
(Technical note: if the object supports the descriptionWithLocale:
message, it will be sent that instead.)