Instantly share code, notes, and snippets.

Embed
What would you like to do?
Only assigning to a __block variable in one of the blocks. I wish this was an error.
#import "Example.h" // https://gist.github.com/hborders/2af9b39e27b62ef9e68c65085126fe4a
- (void)missingAssignment {
Example * _Nonnull fooExample = [[ExampleFoo alloc] initWithF:@"foo"
g:@"goo"];
NSNumber * _Nonnull __block number;
[fooExample switchFoo:^(ExampleFoo * _Nonnull foo_) {
number = @(foo_.f.length + foo_.g.length);
}
bar:^(ExampleBar * _Nonnull bar_) {
// should be:
// number = @(bar_.b.length + bar.c.length);
@(bar_.b.length + bar.c.length);
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment