summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLOnTouchEvent.m
blob: a05291f290ca0b76d77af3f790c52d8cfc85dad1 (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
//  SDLOnTouchEvent.m
//

#import "SDLOnTouchEvent.h"

#import "SDLNames.h"
#import "SDLTouchEvent.h"

@implementation SDLOnTouchEvent

- (instancetype)init {
    if (self = [super initWithName:SDLNameOnTouchEvent]) {
    }
    return self;
}

- (void)setType:(SDLTouchType)type {
    if (type != nil) {
        [parameters setObject:type forKey:SDLNameType];
    } else {
        [parameters removeObjectForKey:SDLNameType];
    }
}

- (SDLTouchType)type {
    NSObject *obj = [parameters objectForKey:SDLNameType];
    return (SDLTouchType)obj;
}

- (void)setEvent:(NSMutableArray<SDLTouchEvent *> *)event {
    if (event != nil) {
        [parameters setObject:event forKey:SDLNameEvent];
    } else {
        [parameters removeObjectForKey:SDLNameEvent];
    }
}

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

@end