Skip to content

Instantly share code, notes, and snippets.

@vinnybad
Created September 12, 2016 02:30
Show Gist options
  • Save vinnybad/285204e1ee3a8c471b30e177265100de to your computer and use it in GitHub Desktop.
Save vinnybad/285204e1ee3a8c471b30e177265100de to your computer and use it in GitHub Desktop.
/**
* Lazy Getter
*
* Helps reduce silly errors when writing lazy getters.
*/
#define ADD_LAZY_GETTER(type, name, initialValueBlock) \
-(type)name \
{ \
if (!_##name) { \
_##name = initialValueBlock(); \
} \
return _##name; \
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment