summaryrefslogtreecommitdiff
path: root/SmartDeviceLink-iOS/SmartDeviceLink/SDLImageField.m
blob: 8109c9bd8d9736cca9d39942454d05bf61ee554c (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
//  SDLImageField.m
//
//  Copyright (c) 2014 Ford Motor Company. All rights reserved.

#import "SDLImageField.h"

#import "SDLNames.h"
#import "SDLFileType.h"

@implementation SDLImageField

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

-(id) 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 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 isKindOfClass:SDLImageResolution.class]) {
        return (SDLImageResolution*)obj;
    } else {
        return [[SDLImageResolution alloc] initWithDictionary:(NSMutableDictionary*)obj];
    }
}

@end