summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLSeatMemoryAction.m
blob: 5e69f94dc3bd7d55beae0a5c18ebfc71503bb66f (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
58
59
60
61
62
//  SDLSeatMemoryAction.m
//

#import "SDLSeatMemoryAction.h"
#import "SDLRPCParameterNames.h"
#import "NSMutableDictionary+Store.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLSeatMemoryAction

- (instancetype)initWithId:(UInt8)id action:(SDLSeatMemoryActionType)action {
    self = [super init];
    if (!self) {
        return nil;
    }

    self.id = @(id);
    self.action = action;

    return self;
}

- (instancetype)initWithId:(UInt8)id label:(nullable NSString*)label action:(SDLSeatMemoryActionType)action {
    self = [self initWithId:id action:action];
    if (!self) {
        return nil;
    }

    self.label = label;
    return self;
}

- (void)setId:(NSNumber<SDLInt> *)id {
    [store sdl_setObject:id forName:SDLRPCParameterNameId];
}

- (NSNumber<SDLInt> *)id {
    NSError *error;
    return [store sdl_objectForName:SDLRPCParameterNameId ofClass:NSNumber.class error:&error];
}

- (void)setLabel:(nullable NSString *)label {
    [store sdl_setObject:label forName:SDLRPCParameterNameLabel];
}

- (nullable NSString *)label {
    return [store sdl_objectForName:SDLRPCParameterNameLabel ofClass:NSString.class];
}

- (void)setAction:(SDLSeatMemoryActionType)action {
    [store sdl_setObject:action forName:SDLRPCParameterNameAction];
}

- (SDLSeatMemoryActionType)action {
    NSError *error;
    return [store sdl_enumForName:SDLRPCParameterNameAction error:&error];
}
@end


NS_ASSUME_NONNULL_END