DKUserDictionary 1.0.1

DKUserDictionary 1.0.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2014年12月

未声明维护。



@description

这个类可以像使用NSDictionary一样容易地使用NSUserDefaults。

@如何使用

可以使用像NSDictionary一样。

DKUserDictionary.d[@"version"] = @"1.0.0";
NSString *version = DKUserDictionary.d[@"version"];

// and use conscious of the type. 

DKUserDictionary *d = DKUserDictionary.d;
NSNumber *num = DKUserDictionary.number[@"number"]; // also DKUserDictionary.d[@"number"]
NSString *str = DKUserDictionary.string[@"string"]; // also DKUserDictionary.d[@"string"]
NSArray *arr = DKUserDictionary.array[@"array"]; // also DKUserDictionary.d[@"array"]
NSDictionary *dic = DKUserDictionary.dictionary[@"dictionary"]; // also DKUserDictionary.d[@"dictionary"]
NSData *data = DKUserDictionary.data[@"data"]; // also DKUserDictionary.d[@"data"]
NSURL *URL = DKUserDictionary.URL[@"URL"]; // also DKUserDictionary.d[@"URL"]

DKUserDictionary.number[@"number"] = @(100); // also DKUserDictionary.d[@"number"]
DKUserDictionary.string[@"string"] = @"foo"; // also DKUserDictionary.d[@"string"]
DKUserDictionary.array[@"array"] = @[@"arrya"]; // also DKUserDictionary.d[@"array"]
DKUserDictionary.dictionary[@"dictionary"] = @{@"key": @"value"}; // also DKUserDictionary.d[@"dictionary"]
DKUserDictionary.data[@"data"] = [@"" dataUsingEncoding:NSUTF8StringEncoding]; // also DKUserDictionary.d[@"data"]
DKUserDictionary.URL[@"URL"] = [NSURL URLWithString:@"http://xxx.com"]; // also DKUserDictionary.d[@"URL"]

// not object
NSInteger _integer = DKUserDictionary._integer(@"integer");
float _float = DKUserDictionary._float(@"float");
double _double = DKUserDictionary._double(@"double");
BOOL _bool = DKUserDictionary._bool(@"bool");
DKUserDictionary._setInteger(@"integer", 100);
DKUserDictionary._setFloat(@"float", 100.f);
DKUserDictionary._setDouble(@"double", 100.f);
DKUserDictionary._setBool(@"bool", YES);


// DKUserDictionary cache default, so not neccessary call synchronize.
// because regist and get/set call through DKUserDefaults.
// cache have old saved defaults too.

[DKUserDictionary.d registerDefaults:@{@"register": @"register"}];