Skip to content

Instantly share code, notes, and snippets.

@zwaldowski
Created September 7, 2017 13:53
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 zwaldowski/b0b99edfc1cbbeb5341cbe1c1a401baa to your computer and use it in GitHub Desktop.
Save zwaldowski/b0b99edfc1cbbeb5341cbe1c1a401baa to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
typedef void(^SomeBlock)(void);
@interface Foo: NSObject
// If this one isn't marked `_Nonnull`, a caller of the class
// won't warn.
- (void)doAThingWithCompletionHandler:(_Nonnull SomeBlock)handler;
@end
@implementation Foo
// If this one isn't marked `_Nonnull`, the caller in `-test`
// won't warn.
- (void)doAThingWithCompletionHandler:(_Nonnull SomeBlock)handler {
handler();
}
- (void)test {
// warning
[self doAThingWithCompletionHandler:nil];
}
@end
int main(int argc, char *argv[]) {
@autoreleasepool {
Foo *f = [Foo new];
[f doAThingWithCompletionHandler:^(void) {
NSLog(@"!");
}];
// warning... also segfaults, cuz it's just a warning!
[f doAThingWithCompletionHandler:nil];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment