Andrea
Andrea

Reputation: 437

Alert window on cancellation row of tableview

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?

Upvotes: 0

Views: 199

Answers (1)

user1804762
user1804762

Reputation:

    // [_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;
}

Upvotes: 1

Related Questions