Created
September 7, 2017 13:53
-
-
Save zwaldowski/b0b99edfc1cbbeb5341cbe1c1a401baa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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