A quick glance at StackOverflow says this is done by a variable declaration directly within the switch’s compound statement. But I don’t think I have one:
- (IBAction)openDocument:(id)sender
{
NSOpenPanel * const panel = [NSOpenPanel openPanel];
panel.allowsMultipleSelection = YES;
panel.delegate = self;
[panel beginWithCompletionHandler:^(NSInteger result){
switch (result) {
case NSFileHandlingPanelOKButton:
[[panel URLs] enumerateObjectsUsingBlock:^(NSURL *obj, NSUInteger idx, BOOL *stop){
id const browser = [PrBrowserController createPagelessBrowser];
[browser showWindow:sender];
[browser loadPage:obj];
}];
break;
default:
break;
}
}];
}
Some of the responses think it’s a bug. The article is a couple of years old; the bug still hasn’t been fixed, or did I mess up somewhere? I guess I’ll work around it with an if-statement.