Created
May 27, 2011 17:24
-
-
Save vincentlg/995727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
window = [[UIWindow alloc] initWithFrame:[ [UIScreen mainScreen] bounds]]; | |
[window makeKeyAndVisible]; | |
//init du modèle | |
model = [ClockModel new]; | |
//init de la vue | |
ClockView *view = [[ClockView alloc]initWithFrame:CGRectMake(10, 30,360.0, 20.0)]; | |
view.controller=self; | |
//Ajout de la vue clockView | |
[window addSubview:view]; | |
[view release]; | |
//init controlleur (call pendulumSwing chaque seconde) | |
self.pendulum = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(pendulumSwing:) userInfo:nil repeats:YES]; | |
return YES; | |
} | |
-(void)pendulumSwing:(NSTimer*)theTimer //Met à jour les propriétés de l'objet clockModel à chaque seconde | |
{ | |
NSDateComponents *comp = [[NSCalendar currentCalendar]components:(NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit)fromDate:[NSDate date]]; | |
[self setValue:[NSNumber numberWithInt:[comp hour]] forKeyPath:@"model.hour"]; | |
[self setValue:[NSNumber numberWithInt:[comp minute]] forKeyPath:@"model.minute"]; | |
[self setValue:[NSNumber numberWithInt:[comp second]] forKeyPath:@"model.second"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment