May 27, 2014

Fast food objective-c (part 8) : Logging

Logging messages to the console in Objective-C is very simple. In fact, the NSLog() function is nearly identical to the C printf() function, except there's an additional %@ token for objects.

NSLog ( @"The current date and time is: %@", [NSDate date] );

You can log an object to the console. The NSLog function calls the description method on the object, and prints the NSString which is returned. You can override the description method in your class to return a custom string.

No comments:

Post a Comment