Question

I have a NSTableView connected to an arraycontroller, I would like that when the user click on the cancel button of the line, an alert window will appear that asks for confirmation before deleting. How can I do?

Was it helpful?

Solution

    // [_window makeKeyAndOrderFront:nil];

NSAlert *myAlert = [NSAlert alertWithMessageText:@"A message from the bottle"
                                   defaultButton:@"No"
                                 alternateButton:@"Yes"
                                     otherButton:@""
                       informativeTextWithFormat:@"Blah Blah\n\Blah!\nProceed?\n"
                    ];

switch ([myAlert runModal]) {

    case 0: // alternateButton
        NSBeep();
        break;

    case  1: // defaultButton
        NSBeep();
        break;

    default:
        break;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top