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

#import "SDLGetWaypointsResponse.h"

#import "SDLLocationDetails.h"
#import "SDLNames.h"

@implementation SDLGetWayPointsResponse

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

- (void)setWaypoints:(NSArray<SDLLocationDetails *> *)waypoints {
    if (waypoints != nil) {
        parameters[SDLNameWaypoints] = waypoints;
    } else {
        [parameters removeObjectForKey:SDLNameWaypoints];
    }
}

- (NSArray<SDLLocationDetails *> *)waypoints {
    NSMutableArray *array = [parameters objectForKey:SDLNameWaypoints];
    if ([array count] < 1 || [[array objectAtIndex:0] isKindOfClass:SDLLocationDetails.class]) {
        return [array copy];
    } else {
        NSMutableArray *newList = [NSMutableArray arrayWithCapacity:[array count]];
        for (NSDictionary *dict in array) {
            [newList addObject:[[SDLLocationDetails alloc] initWithDictionary:(NSMutableDictionary *)dict]];
        }
        return [newList copy];
    }
}

@end

@implementation SDLGetWaypointsResponse

@end