forked from avh4/time-tracker-for-mac
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTProject.m
89 lines (76 loc) · 1.9 KB
/
TProject.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// TProject.m
// Time Tracker
//
// Created by Ivan Dramaliev on 10/18/05.
// Copyright 2005 __MyCompanyName__. All rights reserved.
//
#import "TProject.h"
@implementation TProject
- (id) init
{
[self setName: @"Untitled"];
_tasks = [NSMutableArray new];
return self;
}
- (NSString *) name
{
return _name;
}
- (void) setName: (NSString *) name
{
[name retain];
[_name release];
_name = name;
}
- (NSMutableArray *) tasks
{
return _tasks;
}
- (void) addTask: (TTask *) task
{
[_tasks addObject: task];
}
- (int) totalTime
{
int _totalTime = 0;
int i;
for (i = 0; i < [_tasks count]; i++) {
_totalTime += [[_tasks objectAtIndex: i] totalTime];
}
return _totalTime;
}
- (void)encodeWithCoder:(NSCoder *)coder
{
//[super encodeWithCoder:coder];
if ( [coder allowsKeyedCoding] ) {
[coder encodeObject:_name forKey:@"PName"];
[coder encodeObject:_tasks forKey:@"PTasks"];
} else {
[coder encodeObject:_name];
[coder encodeObject:_tasks];
}
return;
}
- (id)initWithCoder:(NSCoder *)coder
{
//self = [super initWithCoder:coder];
if ( [coder allowsKeyedCoding] ) {
// Can decode keys in any order
_name = [[coder decodeObjectForKey:@"TName"] retain];
_tasks = [[NSMutableArray arrayWithArray: [coder decodeObjectForKey:@"PTasks"]] retain];
} else {
// Must decode keys in same order as encodeWithCoder:
_name = [[coder decodeObject] retain];
_tasks = [[NSMutableArray arrayWithArray: [coder decodeObject]] retain];
}
return self;
}
@end
// This initialization function gets called when we import the Ruby module.
// It doesn't need to do anything because the RubyCocoa bridge will do
// all the initialization work.
// The rbiphonetest test framework automatically generates bundles for
// each objective-c class containing the following line. These
// can be used by your tests.
void Init_TProject() { }