Skip to content

Instantly share code, notes, and snippets.

@bkobilansky
Last active February 27, 2017 05:40
Show Gist options
  • Save bkobilansky/402ea6dab7fe782a5e5caab3e564347c to your computer and use it in GitHub Desktop.
Save bkobilansky/402ea6dab7fe782a5e5caab3e564347c to your computer and use it in GitHub Desktop.
Objective-C blocks empty param list is not void
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// note that an empty list here doesn't mean "no params"
void (^printNSArray)();
printNSArray = ^(NSArray *items) {
// deliberately safe to prove a point
NSLog(@"%@", items);
};
// an empty list means we actually pass whatever we'd like
printNSArray(@[@"foo", @"bar", @"baz"]);
printNSArray(@"quux");
printNSArray([[NSObject alloc] init]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment