/
TMTimer.m
49 lines (40 loc) · 1.03 KB
/
TMTimer.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// TMTimer.m
// Time Me
//
// Created by Ryan Carmelo Briones on 9/21/08.
//
#import "TMTimer.h"
@implementation TMTimer
- (id) initWithDescription: (NSString *) newDescription {
[super init];
timerDescription = newDescription;
createdAt = [NSCalendarDate calendarDate];
durationInSeconds = 0;
stopped = NO;
return self;
}
@synthesize timerDescription;
@synthesize createdAt;
@synthesize durationInSeconds;
@synthesize stopped;
- (void) startTimer {
}
- (void) restartTimer {
stopped = NO;
}
- (void) stopTimer {
stopped = YES;
}
- (void) tickTimer {
if(![self stopped]) {
durationInSeconds++;
}
}
- (NSDictionary *) attributesForTimer {
NSNumber *durationAsObject = [NSNumber numberWithInteger: self.durationInSeconds];
NSArray *values = [NSArray arrayWithObjects: self.timerDescription, self.createdAt, durationAsObject, nil];
NSArray *keys = [NSArray arrayWithObjects: @"timerDescription", @"createdAt", @"durationInSeconds", nil];
return [NSDictionary dictionaryWithObjects: values forKeys: keys];
}
@end