Skip to content

Instantly share code, notes, and snippets.

@ricardopereira
Forked from steipete/PSPDFBlockAssert.m
Created January 14, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardopereira/e07ec9cfd2e54c52af75 to your computer and use it in GitHub Desktop.
Save ricardopereira/e07ec9cfd2e54c52af75 to your computer and use it in GitHub Desktop.
Check if object is a block - nice for assertions.
PSPDF_EXTERN BOOL PSPDFIsBlock(id _Nullable block) {
static Class blockClass;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
blockClass = [^{} class];
while ([blockClass superclass] != NSObject.class) {
blockClass = [blockClass superclass];
}
});
return [block isKindOfClass:blockClass];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment