0

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?

Andrea
  • 427
  • 3
  • 16

1 Answers1

1
    // [_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;
}
  • it works! could you tell me what is the code that corresponds to the received action "remove" of arraycontroller? – Andrea Nov 08 '12 at 23:20
  • First u remove the object in the array (removeObjectAtIndex) Second u update the table with [table reloadData] –  Nov 09 '12 at 09:19
  • yeah sorry I never used an arrayController, the removeObjectAtIndex: is for an array. See doc for NSArrayController or let the code completion help you, is starts probably also with "remove". –  Nov 09 '12 at 13:35