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


#import "SDLReadDIDResponse.h"

#import "SDLDIDResult.h"
#import "SDLNames.h"

@implementation SDLReadDIDResponse

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

- (void)setDidResult:(NSMutableArray<SDLDIDResult *> *)didResult {
    if (didResult != nil) {
        [parameters setObject:didResult forKey:SDLNameDIDResult];
    } else {
        [parameters removeObjectForKey:SDLNameDIDResult];
    }
}

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

@end