Latest 0.1.2
Homepage https://github.com/xingheng/UserDefaultsHelper
License MIT
Platforms ios 6.0
Frameworks Foundation
Authors

Version
License
Platform

NSString strUserDefaultKey = @"fooKey";
[[NSUserDefaults standardUserDefaults] setObject:@"fooValue" forKey:strUserDefaultKey];
NSString
obj = [[NSUserDefaults standardUserDefaults] objectForKey:strUserDefaultKey];

Tired of the above usage in your project? Why not UserDefaultsHelper? It’s simple and brief!

Let’s do a replacement for the above code,

NSString strUserDefaultKey = @"fooKey";
SetUserDefaultObject(strUserDefaultKey, @"fooValue");
NSString
obj = UserDefaultObject(strUserDefaultKey);

Certainly, there is a map list for all kinds of objects for you,

Type Getter Setter
Integer UserDefaultInteger SetUserDefaultInteger
BOOL UserDefaultBool SetUserDefaultBool
float UserDefaultFloat SetUserDefaultFloat
double UserDefaultDouble SetUserDefaultDouble
NSURL UserDefaultURL SetUserDefaultURL
NSString UserDefaultString SetUserDefaultObject
NSArray UserDefaultArray SetUserDefaultObject
NSDictionary UserDefaultDictionary SetUserDefaultObject
NSData UserDefaultData SetUserDefaultObject
id UserDefaultObject SetUserDefaultObject

Besides, some useful helper functions serve for you, too.

// Send sync message to standard userdefault explicitly.
void UserDefaultSynchronize(void);  

// Remove the specified key from userdefault.
void UserDefaultRemoveKey(NSString *key);

// Register the specified default dictionary to userdefault.
void UserDefaultRegister(NSDictionary *defaultDictionary);

// Return all the values in userdefault as a dictionary.
NSDictionary *UserDefaultAllValue(void);

// Remove all the custome values except the specified keys' pair.
void UserDefaultClearAllExcept(NSArray *keys);

// Remove all the custom values.
void UserDefaultClearAll(void);

Installation

UserDefaultsHelper is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "UserDefaultsHelper"

Or just download a copy of folder UserDefaultsHelper to your project.

Author

Will Han, [email protected]

License

UserDefaultsHelper is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "UserDefaultsHelper",
    "version": "0.1.2",
    "summary": "A wrapper with C-style for NSUserDefaults class, in Objective-C.",
    "description": "Replace the duplicated [NSUserDefaults standardUserDefaults] methods with C-style functions for easy call.",
    "homepage": "https://github.com/xingheng/UserDefaultsHelper",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Will Han": "[email protected]"
    },
    "source": {
        "git": "https://github.com/xingheng/UserDefaultsHelper.git",
        "tag": "0.1.2"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source_files": "UserDefaultsHelper/**/*",
    "public_header_files": "UserDefaultsHelper/UserDefault.h",
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This