summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLImageField.m
blob: af4f15517f49aefa23fa85c292969c98a841fd2e (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//  SDLImageField.m
//

#import "SDLImageField.h"

#import "SDLFileType.h"
#import "SDLImageFieldName.h"
#import "SDLImageResolution.h"
#import "SDLNames.h"


@implementation SDLImageField

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

- (instancetype)initWithDictionary:(NSMutableDictionary *)dict {
    if (self = [super initWithDictionary:dict]) {
    }
    return self;
}

- (void)setName:(SDLImageFieldName *)name {
    if (name != nil) {
        [store setObject:name forKey:NAMES_name];
    } else {
        [store removeObjectForKey:NAMES_name];
    }
}

- (SDLImageFieldName *)name {
    NSObject *obj = [store objectForKey:NAMES_name];
    if (obj == nil || [obj isKindOfClass:SDLImageFieldName.class]) {
        return (SDLImageFieldName *)obj;
    } else {
        return [SDLImageFieldName valueOf:(NSString *)obj];
    }
}

- (void)setImageTypeSupported:(NSMutableArray *)imageTypeSupported {
    if (imageTypeSupported != nil) {
        [store setObject:imageTypeSupported forKey:NAMES_imageTypeSupported];
    } else {
        [store removeObjectForKey:NAMES_imageTypeSupported];
    }
}

- (NSMutableArray *)imageTypeSupported {
    NSMutableArray *array = [store objectForKey:NAMES_imageTypeSupported];
    if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLFileType.class]) {
        return array;
    } else {
        NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]];
        for (NSString *enumString in array) {
            [newList addObject:[SDLFileType valueOf:enumString]];
        }
        return newList;
    }
}

- (void)setImageResolution:(SDLImageResolution *)imageResolution {
    if (imageResolution != nil) {
        [store setObject:imageResolution forKey:NAMES_imageResolution];
    } else {
        [store removeObjectForKey:NAMES_imageResolution];
    }
}

- (SDLImageResolution *)imageResolution {
    NSObject *obj = [store objectForKey:NAMES_imageResolution];
    if (obj == nil || [obj isKindOfClass:SDLImageResolution.class]) {
        return (SDLImageResolution *)obj;
    } else {
        return [[SDLImageResolution alloc] initWithDictionary:(NSMutableDictionary *)obj];
    }
}

@end