{"id":20010103,"url":"https://github.com/cxa/kissnsuserdefaults","last_synced_at":"2025-05-04T19:36:01.256Z","repository":{"id":6166299,"uuid":"7396011","full_name":"cxa/KissNSUserDefaults","owner":"cxa","description":"Keep NSUserDefaults simple, stupid. Access NSUserDefaults key using property, without subclassing.","archived":false,"fork":false,"pushed_at":"2017-12-12T15:49:15.000Z","size":58,"stargazers_count":46,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-21T15:16:40.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cxa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-01T14:30:46.000Z","updated_at":"2022-03-03T19:49:03.000Z","dependencies_parsed_at":"2022-09-08T21:02:31.864Z","dependency_job_id":null,"html_url":"https://github.com/cxa/KissNSUserDefaults","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FKissNSUserDefaults","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FKissNSUserDefaults/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FKissNSUserDefaults/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cxa%2FKissNSUserDefaults/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cxa","download_url":"https://codeload.github.com/cxa/KissNSUserDefaults/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252390800,"owners_count":21740388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T07:18:28.470Z","updated_at":"2025-05-04T19:36:00.884Z","avatar_url":"https://github.com/cxa.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KissNSUserDefaults\n\nKeep it simple, stupid!\n\nDirectly hard code to access keys of `NSUserDefaults` is very boring, and painful because `NSUserDefaultsDidChangeNotification` contains no user info.\n\nif we can access keys via properties and listen to the specific `NSUserDefaults` key change, life must be more easier.\n\nThis is what `KissNSUserDefaults` project borns to be. What you need to do is to declare properties in header and `@dynamic` all in implementation. Run `+kiss_setup` or `+kiss_setupWithCustomKeys:` in `+load` will generate all accessors for you. \n\n## Usage\n\nAdd `NSUserDefaults+KissNSUserDefaults.h` and `NSUserDefaults+KissNSUserDefaults.m` to your project. Make your own `NSUserDefaults` category, import `NSUserDefaults+KissNSUserDefaults.h` and run `+kiss_setup` in your category's `+load`. If you need to transit old keys, or need to keep key and property in its own name, you can run `+kiss_setupWithCustomKeys:` with your own key-property pairs dictionary. And you can add an observer at somewhere for `KissNSUserDefaultsDidChangeNotification` which contains user info for key and value.\n\nCheck demo project for details.\n\n### `NSUserDefaults+KissDemo.h`\n\n    #import \"NSUserDefaults+KissNSUserDefaults.h\"\n    \n    extern NSString * const kMyCustomKey;\n    \n    @interface NSUserDefaults (KissDemo)\n    \n    @property (nonatomic, strong) NSString *string;\n    @property (nonatomic) NSInteger integer;\n    @property (nonatomic) float floatValue;\n    @property (nonatomic) BOOL boolValue;\n    @property (nonatomic) double doubleValue;\n    \n    @end\n\t\n### `NSUserDefaults+KissDemo.m`\n\n    #import \"NSUserDefaults+KissDemo.h\"\n    \n    NSString * const kMyCustomKey = @\"im.cxa.myCustomKey\";\n    \n    @implementation NSUserDefaults (KissDemo)\n    @dynamic string, integer, floatValue, boolValue, doubleValue;\n    \n    + (void)load\n    {\n      // run [self kiss_setup] if you don't need custom keys\n      [self kiss_setupWithCustomKeys:@{@\"doubleValue\" : kMyCustomKey}];\n    }\n    \n    @end\n\t\t\n## Creator\n\n* GitHub: \u003chttps://github.com/cxa\u003e\n* Twitter: [@_cxa](https://twitter.com/_cxa)\n* Apps available in App Store: \u003chttp://lazyapps.com\u003e\n\n## License\n\nUnder the MIT license. See the LICENSE file for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxa%2Fkissnsuserdefaults","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxa%2Fkissnsuserdefaults","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxa%2Fkissnsuserdefaults/lists"}