summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLTouchEvent.m
blob: 632bc6994bce3d9c0323c3155065832e4cc07b1d (plain)
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
//  SDLTouchEvent.m
//


#import "SDLTouchEvent.h"

#import "SDLNames.h"
#import "SDLTouchCoord.h"

@implementation SDLTouchEvent

- (void)setTouchEventId:(NSNumber<SDLInt> *)touchEventId {
    if (touchEventId != nil) {
        [store setObject:touchEventId forKey:SDLNameId];
    } else {
        [store removeObjectForKey:SDLNameId];
    }
}

- (NSNumber<SDLInt> *)touchEventId {
    return [store objectForKey:SDLNameId];
}

- (void)setTimeStamp:(NSMutableArray<NSNumber<SDLInt> *> *)timeStamp {
    if (timeStamp != nil) {
        [store setObject:timeStamp forKey:SDLNameTimestamp];
    } else {
        [store removeObjectForKey:SDLNameTimestamp];
    }
}

- (NSMutableArray<NSNumber<SDLInt> *> *)timeStamp {
    return [store objectForKey:SDLNameTimestamp];
}

- (void)setCoord:(NSMutableArray<SDLTouchCoord *> *)coord {
    if (coord != nil) {
        [store setObject:coord forKey:SDLNameCoordinate];
    } else {
        [store removeObjectForKey:SDLNameCoordinate];
    }
}

- (NSMutableArray<SDLTouchCoord *> *)coord {
    NSMutableArray<SDLTouchCoord *> *array = [store objectForKey:SDLNameCoordinate];
    if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLTouchCoord.class]) {
        return array;
    } else {
        NSMutableArray<SDLTouchCoord *> *newList = [NSMutableArray arrayWithCapacity:[array count]];
        for (NSDictionary<NSString *, id> *dict in array) {
            [newList addObject:[[SDLTouchCoord alloc] initWithDictionary:(NSDictionary *)dict]];
        }
        return newList;
    }
}

@end