forked from atg/Ingredients
-
Notifications
You must be signed in to change notification settings - Fork 2
/
IGKAnnotation.m
74 lines (58 loc) · 1.53 KB
/
IGKAnnotation.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
//
// IKGAnnotation.m
// Ingredients
//
// Created by Jean-Nicolas Jolivet on 10-04-30.
// Written in 2010 by SilverCocoa.
//
#import "IGKAnnotation.h"
#import "NSString+Utilities.h"
@implementation IGKAnnotation
@synthesize docurl;
@synthesize submitter_name;
@synthesize uuid;
@synthesize annotation;
@synthesize createdDate;
+ (IGKAnnotation *)createAnnotation
{
return [[self alloc] initAndGenerateUUID];
}
- (id)init
{
if(self = [super init])
{
}
return self;
}
- (id)initAndGenerateUUID
{
if(self = [self init])
{
[self setUuid:[NSString stringByGeneratingUUID]];
NSUInteger today = (NSTimeInterval)[[NSDate date] timeIntervalSince1970];
[self setCreatedDate:[NSNumber numberWithUnsignedInt:today]];
}
return self;
}
- (id)initWithDict:(NSDictionary *)dic
{
if (self = [self init]) {
[self setDocurl:[dic objectForKey:@"docurl"]];
[self setSubmitter_name:[dic objectForKey:@"submitter_name"]];
[self setUuid:[dic objectForKey:@"uuid"]];
[self setAnnotation:[dic objectForKey:@"annotation"]];
[self setCreatedDate:[dic objectForKey:@"createdDate"]];
}
return self;
}
- (NSDictionary *)annotationAsDict
{
NSMutableDictionary *returnDic = [[NSMutableDictionary alloc] init];
[returnDic setObject:[self docurl] forKey:@"docurl"];
[returnDic setObject:[self submitter_name] forKey:@"submitter_name"];
[returnDic setObject:[self uuid] forKey:@"uuid"];
[returnDic setObject:[self annotation] forKey:@"annotation"];
[returnDic setObject:[self createdDate] forKey:@"createdDate"];
return returnDic;
}
@end