Question about dealloc method


#1

On page 118 or 119 (I’m using a Kindle app on a Mac so can’t tell completely), when we’re creating the Asset class, we’re told to add a dealloc method to Asset.m with the following code:

- (void)dealloc { NSLog(@"deallocating %@", self); }

Why isn’t it

or

(since we’ve already added the “label” instance variable and property to Asset.h)?


#2

Great question. I can’t quite remember which chapter we answer it in, so I’ll just braindump here:

The “%@” substitution token tells the NSLog() fuction to expect an NSString instance in the appropriate place. If the object that you provide isn’t already an NSString instance, however, then the NSLog() function will send your object the -description message, and use that string.