description and %@

In calls to NSLog(), you have been using the token %@ to get an object to describe itself. The %@ token sends a description message to the object pointed to by the corresponding variable.

The description method returns a string that is a useful description of an instance of the class. It is an NSObject method, so every object implements it. The default NSObject implementation returns the object’s address in memory as a string.

However, a memory address is often not the most useful way to describe an instance. A class can override description:. For example, NSDate overrides description to return the date/time that the instance holds. NSString overrides description to return the string itself.

In BNREmployee.m ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.