RMConfiguration.m
1.44 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
76
77
78
//
// RMConfiguration.m
// MapView
//
// Created by Hauke Brandes on 28.10.08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "RMConfiguration.h"
static RMConfiguration* RMConfigurationSharedInstance = nil;
@implementation RMConfiguration
+ (RMConfiguration*) configuration
{
@synchronized (RMConfigurationSharedInstance) {
if (RMConfigurationSharedInstance != nil) return RMConfigurationSharedInstance;
RMConfigurationSharedInstance = [[RMConfiguration alloc]
initWithPath: [[NSBundle mainBundle] pathForResource:@"routeme" ofType:@"plist"]];
return RMConfigurationSharedInstance;
}
return nil;
}
- (RMConfiguration*) initWithPath: (NSString*) path
{
self = [super init];
if (self==nil) return nil;
NSData *plistData;
NSString *error;
NSPropertyListFormat format;
if (path==nil)
{
propList = nil;
return self;
}
NSLog(@"reading configuration from %@", path);
plistData = [NSData dataWithContentsOfFile:path];
propList = [[NSPropertyListSerialization
propertyListFromData:plistData
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&error] retain];
if(!propList)
{
NSLog(@"problem reading from %@: %@", path, error);
[error release];
}
return self;
}
- (void) dealloc
{
[propList release];
[super dealloc];
}
- (NSDictionary*) cacheConfiguration
{
if (propList==nil) return nil;
return [propList objectForKey: @"caches"];
}
@end