Created
December 9, 2011 02:57
-
-
Save shanev/1449946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// StachifyDefaults.m | |
// | |
// Created by Shane Vitarana on 12/8/11. | |
// Copyright (c) 2011 CrimsonJet LLC. All rights reserved. | |
// | |
#import "StachifyDefaults.h" | |
@implementation StachifyDefaults | |
- (id)init | |
{ | |
self = [super init]; | |
if (self) { | |
defaults = [NSUserDefaults standardUserDefaults]; | |
} | |
return self; | |
} | |
+ (id)sharedDefaults | |
{ | |
static dispatch_once_t pred = 0; | |
__strong static id _sharedObject = nil; | |
dispatch_once(&pred, ^{ | |
_sharedObject = [[self alloc] init]; | |
}); | |
return _sharedObject; | |
} | |
- (void)loadDefaultDefaults | |
{ | |
NSString *path = [[NSBundle mainBundle] pathForResource:@"UserDefaults" ofType:@"plist"]; | |
NSDictionary *appDefaults = [NSDictionary dictionaryWithContentsOfFile:path]; | |
[defaults registerDefaults:appDefaults]; | |
} | |
- (BOOL)isServiceEnabled:(NSString *)service | |
{ | |
return [defaults boolForKey:[NSString stringWithFormat:@"service.%@.enabled", service]]; | |
} | |
- (void)setServiceEnabled:(BOOL)on forService:(NSString *)service | |
{ | |
[defaults setBool:on forKey:[NSString stringWithFormat:@"service.%@.enabled", service]]; | |
[defaults synchronize]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment