I have the following code in a ViewController in my OS X app:
NSAlert *alert = [NSAlert new];
alert.messageText = @"Connection error";
alert.informativeText = @"You do not appear to be connected to the internet";
[alert addButtonWithTitle:@"Third button"];
[alert addButtonWithTitle:@"Second button"];
[alert addButtonWithTitle:@"Ok"];
[alert beginSheetModalForWindow:[[self view] window] completionHandler:^(NSInteger result) {
NSLog(@"Success");
}];
// [alert runModal];
When this code executes nothing happens. If I comment out the beginSheetModalForWindow line, and uncomment [alert runModal], then the alert is displayed as expected.
What am I doing wrong here that it doesn't display as a sheet?