Permalink
Browse files

new methods to be more inline with NSUserDefaults

  • Loading branch information...
1 parent 8505f59 commit be635dd8024f2f1cdc243bedcd8601961d8745bd @tomcool420 committed Apr 30, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 SMFPreferences.m
View
@@ -63,6 +63,16 @@ -(void)setInteger:(NSInteger)value forKey:(NSString *)defaultName
CFPreferencesSetAppValue((CFStringRef)defaultName, (CFNumberRef)[NSNumber numberWithInteger:value], (CFStringRef)_applicationID);
[self synchronize];
}
+-(void)setDouble:(double)value forKey:(NSString *)defaultName
+{
+ CFPreferencesSetAppValue((CFStringRef)defaultName, (CFNumberRef)[NSNumber numberWithDouble:value], (CFStringRef)_applicationID);
+ [self synchronize];
+}
+-(void)setFloat:(float)value forKey:(NSString *)defaultName
+{
+ CFPreferencesSetAppValue((CFStringRef)defaultName, (CFNumberRef)[NSNumber numberWithFloat:value], (CFStringRef)_applicationID);
+ [self synchronize];
+}
-(BOOL)boolForKey:(NSString *)defaultName
{
id obj = [self objectForKey:defaultName];
@@ -77,6 +87,20 @@ -(NSInteger)integerForKey:(NSString *)defaultName
return [obj integerValue];
return [[_registrationDictionary objectForKey:defaultName] integerValue];
}
+-(double)doubleForKey:(NSString *)defaultName
+{
+ id obj = [self objectForKey:defaultName];
+ if(obj!=nil && [obj respondsToSelector:@selector(doubleValue)])
+ return [obj floatValue];
+ return [[_registrationDictionary objectForKey:defaultName] doubleValue];
+}
+-(float)floatForKey:(NSString *)defaultName
+{
+ id obj = [self objectForKey:defaultName];
+ if(obj!=nil && [obj respondsToSelector:@selector(floatValue)])
+ return [obj floatValue];
+ return [[_registrationDictionary objectForKey:defaultName] floatValue];
+}
-(void)registerDefaults:(NSDictionary *)registrationDictionary {
[_registrationDictionary release];

0 comments on commit be635dd

Please sign in to comment.