-
Notifications
You must be signed in to change notification settings - Fork 2
/
PlistLoader.mm
41 lines (37 loc) · 1.22 KB
/
PlistLoader.mm
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
//
// PlistLoader.m
// DoodleFalling
//
// Created by lim byeong cheol on 11. 9. 23..
// Copyright 2011년 SK M&S. All rights reserved.
//
#import "PlistLoader.h"
@implementation PlistLoader
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
-(NSMutableDictionary *)PlistLoadFromFileName:(NSString *)fileName
{
NSString *fileNameWithExtension=[NSString stringWithFormat:@"%@.plist",fileName];
NSString *documentPath=[self applicationDocumentsDirectory];
NSString *fileNameWithDirectory=[documentPath stringByAppendingPathComponent:fileNameWithExtension];
NSLog(@"Score.plist exists at %@",fileNameWithDirectory);
if (![[NSFileManager defaultManager]fileExistsAtPath:fileNameWithDirectory]) {
fileNameWithDirectory=[[NSBundle mainBundle] pathForResource:fileName ofType:@"plist"];
}
dic=[NSMutableDictionary dictionaryWithContentsOfFile:fileNameWithDirectory];
if (dic==nil) {
NSLog(@"Error reading %@.plist file",fileName);
return nil;
}
return dic;
}
- (NSString *)applicationDocumentsDirectory {
return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
}
@end