-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointController.m
More file actions
75 lines (61 loc) · 1.9 KB
/
PointController.m
File metadata and controls
75 lines (61 loc) · 1.9 KB
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
//
// PointController.m
// FlightNavigator
//
// Created by Yoo Rinjae on 12. 11. 9..
// Copyright (c) 2012년 DearMai. All rights reserved.
//
#import "PointController.h"
#import "DataBuilder.h"
#import "SignificantPoint.h"
static PointController *instance = nil;
@implementation PointController {
}
@synthesize points;
+ (PointController *)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 = [[PointController alloc] initWithBundlePath:bundlePath];
}
}
return instance;
}
- (id)initWithBundlePath:(NSString *)newBundlePath {
if ([self init]) {
DataBuilder *builder = [[DataBuilder alloc] initWithDataPath:newBundlePath];
points = [builder buildSignificantPoint];
}
return self;
}
#pragma -
- (SignificantPoint *)pointObjectAtIndex:(NSUInteger)index {
return [points objectAtIndex:index];
}
- (NSUInteger)countPoints {
return [points count];
}
- (SignificantPoint *)pointObjectAtName:(NSString *)newName {
for (int i = 0; i < [points count]; i++){
SignificantPoint *point = [points objectAtIndex:i];
if([point.name isEqualToString:newName] == YES) {
return point;
}
}
return nil;
}
- (int)pointIndexWithName:(NSString *)newName {
for (int i = 0; i < [points count]; i++){
SignificantPoint *point = [points objectAtIndex:i];
if([point.name isEqualToString:newName] == YES) {
return i;
}
}
return -1;
}
@end