NSDate* date = [NSDate date];
//Create the dateformatter object
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[formatter setDateFormat:@"yyyy-MM-dd"];
//Get the string date
NSString* str = [formatter stringFromDate:date];
//Display on the console
NSLog(str);
//Set in the lable
[dateLabel setText:str];
Objective C elementi BASE:gestione eventi tra classi
/** per registrare un azione in base ad un evento:
*/
// Erase the view when recieving a notification named "shake" from the NSNotificationCenter object
// The "shake" nofification is posted by the PaintingWindow object when user shakes the device
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(eraseView) name:@"shake" object:nil];
/** INVIO dell'evento
*/
// User was shaking the device. Post a notification named "shake".
[[NSNotificationCenter defaultCenter] postNotificationName:@"shake" object:self];