-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFT2GMapsDirectionOutput.m
48 lines (36 loc) · 1.06 KB
/
FT2GMapsDirectionOutput.m
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
//
// FT2GMapsDirectionOutput.m
// Mercedes Map Test
//
// Created by Baldoph Pourprix on 10/04/2013.
// Copyright (c) 2013 Fuerte Int. All rights reserved.
//
#import "FT2GMapsDirectionOutput.h"
#import "FT2GMapsRoute.h"
@interface FT2GMapsDirectionOutput ()
@property (nonatomic, readwrite) NSError *error;
@property (nonatomic, readwrite) FT2GMapsRoute *route; //return the first object of |routes|
@property (nonatomic, readwrite) NSArray *routes;
@end
@implementation FT2GMapsDirectionOutput
#pragma mark - Object lifecycle
- (id)initWithDictionary:(NSDictionary *)dict
{
self = [super init];
if (self) {
NSMutableArray *routes = [NSMutableArray new];
NSArray *routesArray = dict[@"routes"];
[routesArray enumerateObjectsUsingBlock:^(NSDictionary *routeDict, NSUInteger idx, BOOL *stop) {
FT2GMapsRoute *route = [[FT2GMapsRoute alloc] initWithDictionary:routeDict];
[routes addObject:route];
}];
_routes = routes.copy;
}
return self;
}
#pragma mark - Getters
- (FT2GMapsRoute *)route
{
return _routes.count > 0 ? _routes[0] : nil;
}
@end