Inside the example of LotteryEntry.m class at the end was added
- (NSString *) description
result = [[NSString alloc] initWithFormat:@"%@ = %d and %d",
[entryDate descriptionWithCalendarFormat:@"%b %d %Y"],
My questions is:
- why this method has not been declared in the LotteryEntry.h file as other methods?
- If I understand correctly - NSLog call this method?
Thank you very much for assistance![/quote]
- You don’t need to because it is inherited from NSObject, so it’s already declared in NSObject.h (which is in turn imported by Foundation.h)
see developer.apple.com/mac/library/ … ect_Class/
We’re overriding this method because (as you see in Figure 3.8 on page 51) NSObject’s description-method doesn’t know how to get something meaningful out of the LotteryEntry-class and only prints some pointer addresses (I suppose), you’ll read more about this in chapter 5
- Well… sort of Page 38: “With NSLog, we have […] the token %@ to display an object. The object gets sent the message description, and the string it returns replaces %@ in the string.”