Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#define GCSynthesizeUserDefaultsGetter(cls, key, instance, name) \
- (cls *)name { \
if (!instance) { \
id o = [[NSUserDefaults standardUserDefaults] objectForKey:(key)]; \
if (![o isKindOfClass:[cls class]]) o = nil; \
\
[o retain]; \
[instance release]; \
instance = o; \
} \
\
return instance; \
}
#define GCSSynthesizeUserDefaultsSetter(cls, key, instance, setterName) \
- (void)setterName(cls*)o { \
[o retain]; \
[instance release]; \
instance = o; \
\
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; \
[prefs setObject:instance forKey:(key)]; \
[prefs synchronize]; \
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.