-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRouteController.m
65 lines (53 loc) · 1.56 KB
/
RouteController.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// RouteController.m
// FlightNavigator
//
// Created by Yoo Rinjae on 12. 11. 10..
// Copyright (c) 2012년 DearMai. All rights reserved.
//
#import "RouteController.h"
#import "DataBuilder.h"
#import "FlightRoute.h"
static RouteController *instance = nil;
@implementation RouteController {
}
@synthesize routes;
+ (RouteController *)getInstance {
@synchronized(self){
if(instance == nil) {
// 리소스 경로 가져오기
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"point" ofType:@"txt"];
NSRange match = [bundlePath rangeOfString:@"point\\.txt$" options:NSRegularExpressionSearch];
bundlePath = [bundlePath substringToIndex:match.location - 1];
NSLog(@"%d", match.location);
NSLog(@"%@", bundlePath);
instance = [[RouteController alloc] initWithBundlePath:bundlePath];
}
}
return instance;
}
- (id)initWithBundlePath:(NSString *)newBundlePath {
if ([self init]) {
DataBuilder *builder = [[DataBuilder alloc] initWithDataPath:newBundlePath];
routes = [builder buildFlightRoute];
}
return self;
}
#pragma -
- (FlightRoute *)routeAtIndex:(NSUInteger)index {
return [routes objectAtIndex:index];
}
- (NSUInteger)countRoutes {
return [routes count];
}
- (NSInteger)findKeyWithName:(NSString *)name {
NSInteger i = 0;
for(FlightRoute *route in routes){
if([route.name isEqualToString:name] == YES) {
return i;
}
i++;
}
return -1;
}
@end