Ever worked with
NSUserDefaults and tired of handling all the keys? Ever wanted to observe changes without listening to
NSUserDefaultsDidChangeNotification and manually trying to figure out what has changed?
FFUserDefaults is the perfect library for you!
Just create a subclass of
FFUserDefaults and define the properties you need. Then implement them as
FFUserDefaults will do the rest.
How does it work?
FFUserDefaults retrieves all
@dynamic properties at runtime. It then creates accessors for these properties. The values are just stored in the
NSUserDefaults. If you need
NSUserDefaults other than
standardUserDefaults you can just override the getter method
- (NSUserDefaults *)userDefaults; in your subclass and return whatever
NSUserDefaults you would like
FFUserDefaults to use.
What kind of properties can I use?
You can of course use any object property. Further the following primitive data types are supported:
unsigned long long
An example class would look like this.
#import <FFUserDefaults/FFUserDefaults.h> @interface FFExampleSettings : FFUserDefaults @property (nonatomic, strong) NSString *username; @property (nonatomic, strong) NSDate *reminderDate; @property (nonatomic, getter = isReminderEnabled) BOOL reminderEnabled; @end
#import "FFExampleSettings.h" @implementation FFExampleSettings @dynamic username; @dynamic reminderDate; @dynamic reminderEnabled; @end
There's also a sample project.
FFUserDefaults is licensed under MIT. For more information see the