Graphics Programs Reference
In-Depth Information
In
TimeViewController.m
, implement the action method:
- (IBAction)showCurrentTime:(id)sender
{
NSDate *now = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
[timeLabel setText:[formatter stringFromDate:now]];
}
Build and run the application. Tap the
What time is it?
button, and you will see the current
stands.
Figure 7.12 TimeViewController's view on the window