Skip to content

Instantly share code, notes, and snippets.

@cxa
Created September 12, 2011 02:22
Show Gist options
  • Save cxa/1210463 to your computer and use it in GitHub Desktop.
Save cxa/1210463 to your computer and use it in GitHub Desktop.
NSUserDefaults shortcut
#define DEFAULTS(type, key) ([[NSUserDefaults standardUserDefaults] type##ForKey:key])
#define SET_DEFAULTS(Type, key, val) do {\
[[NSUserDefaults standardUserDefaults] set##Type:val forKey:key];\
[[NSUserDefaults standardUserDefaults] synchronize];\
} while (0)
@CocoaBob
Copy link

Very nice idea, but how can we get rid of the warnings like "warning: passing argument 1 of 'setBool:forKey:' makes integer from pointer without a cast"?

@humbroll
Copy link

humbroll commented Dec 4, 2013

Love it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment