Created
July 23, 2010 10:44
-
-
Save matej/487276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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