mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
29 lines
803 B
Objective-C
29 lines
803 B
Objective-C
#import "ConfigHelper.h"
|
|
#import <YAML/YAMLSerialization.h>
|
|
|
|
@implementation ConfigHelper
|
|
|
|
+ (id)valueForKey:(NSString *)key {
|
|
static id yaml;
|
|
|
|
if (!yaml) {
|
|
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
|
NSString *path = [bundle pathForResource:@"config" ofType:@"yml"];
|
|
|
|
NSInputStream *stream = [[NSInputStream alloc] initWithFileAtPath:path];
|
|
yaml = [YAMLSerialization YAMLWithStream:stream
|
|
options:kYAMLReadOptionStringScalars
|
|
error:nil];
|
|
}
|
|
|
|
id data = [yaml objectAtIndex:0];
|
|
NSArray *keyList = [key componentsSeparatedByString:@"."];
|
|
for (NSString *keyPart in keyList) {
|
|
data = [data objectForKey:keyPart];
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
@end
|