Do you have classes like UserDefaultsAdapter and KeychainAdapter that has a lot of duplicated code? This library offers you a solution.
There's a 3 steps to make it work:
- Subclass DVAutoGeneratedProperties
- Override setter and getter block methods
- Add as much class properties as you want
General setter implementation:
+ (dvPropertySetterBlock)setterBlockForTarget:(id)target getterSelector:(SEL)getterSelector {
return ^(id blockSelf, id value) {
// your code here
};
}
General getter implementation:
+ (dvPropertyGetterBlock)getterBlockForTarget:(id)target getterSelector:(SEL)getterSelector {
return ^id(id blockSelf) {
return // your code here
};
}
If you want real usage example, check the implementation of NSUserDefaults facade.
DVAutoGeneratedProperties is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'DVAutoGeneratedProperties'
vdugnist, vdugnist@gmail.com
DVAutoGeneratedProperties is available under the MIT license. See the LICENSE file for more info.