-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.m
57 lines (42 loc) · 1.13 KB
/
Config.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
//
// Config.m
// daily Expenses
//
// Created by renan veloso silva on 09/07/13.
// Copyright (c) 2013 renan veloso silva. All rights reserved.
//
#import "Config.h"
@implementation Config
@synthesize categoryList;
static id _instance;
+ (Config *) sharedInstance{
@synchronized(self){
if (!_instance) {
_instance = [[self alloc] init];
}
}
return _instance;
}
-(id)init{
self = [super init];
if (self) {
[self loadData];
}
return self;
}
-(void)loadData{
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"defaultConfig" ofType:@"plist"];
NSDictionary *plistContent = [NSDictionary dictionaryWithContentsOfFile:plistPath];
categoryList = [[NSDictionary alloc]initWithDictionary:[plistContent objectForKey:@"categories"]];
}
-(UIImage*)getImageByCategoryLabel:(NSString*)label{
NSString *imageName;
for (NSString *key in categoryList) {
imageName = [categoryList objectForKey:key];
if ([key isEqualToString:label]) {
break;
}
}
return [UIImage imageNamed:imageName];
}
@end