Skip to content

Instantly share code, notes, and snippets.

@hborders
Created March 13, 2017 18:05
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 hborders/5c49e5f542245c67af096ae0ced37037 to your computer and use it in GitHub Desktop.
Save hborders/5c49e5f542245c67af096ae0ced37037 to your computer and use it in GitHub Desktop.
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