Skip to content

Instantly share code, notes, and snippets.

@albertodebortoli
Created April 4, 2012 22:29
Show Gist options
  • Save albertodebortoli/2306149 to your computer and use it in GitHub Desktop.
Save albertodebortoli/2306149 to your computer and use it in GitHub Desktop.
Abstract Method macro on iOS
#define DEFINE_ABSTRACT_METHOD(returnType, name)\
- (returnType)name {\
@throw [NSException exceptionWithName:NSInternalInconsistencyException\
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]\
userInfo:nil];\
}
// usage
DEFINE_ABSTRACT_METHOD(<<returnType>>, <<methodNameWithOrWithoutArgs>>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment