Permalink
Browse files

Use setObject instead of setValue to save on user defaults.

  • Loading branch information...
1 parent 3128d85 commit fcfcc4fb208fd685cb10c12b73a164aa038204bd @ettore committed Apr 5, 2013
Showing with 12 additions and 5 deletions.
  1. +9 −2 clcg_device_utils.h
  2. +3 −3 clcg_device_utils.m
View
@@ -36,8 +36,15 @@ extern "C" {
/** Adds `value' to the array pref identified by `key'. */
void clcg_savepref_in_array(NSString *key, NSString *value);
- /** Saves a string pref value to user defaults. */
- void clcg_savepref(NSString *key, NSString *value);
+ /**
+ Saves a pref value to user defaults.
+ @param key The user defaults key.
+ @param value Value to save. The value parameter can be only property list
+ objects: NSData, NSString, NSNumber, NSDate, NSArray, or
+ NSDictionary. For NSArray and NSDictionary objects, their
+ contents must be property list objects.
+ */
+ void clcg_savepref(NSString *key, id<NSCoding> value);
/** Saves a boolean pref value to user defaults. */
void clcg_savepref_bool(NSString *key, BOOL value);
View
@@ -79,15 +79,15 @@ void clcg_savepref_in_array(NSString *key, NSString *value)
newarr = [NSMutableArray arrayWithArray:current];
[newarr addObject:value];
- [defs setValue:newarr forKey:key];
+ [defs setObject:newarr forKey:key];
[defs synchronize];
}
-void clcg_savepref(NSString *key, NSString *value)
+void clcg_savepref(NSString *key, id<NSCoding> value)
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
- [defs setValue:value forKey:key];
+ [defs setObject:value forKey:key];
[defs synchronize];
}

0 comments on commit fcfcc4f

Please sign in to comment.