Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6872665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:57:28+00:00 2026-05-27T03:57:28+00:00

I have a panel xib which is owned by class FooController. FooController also has

  • 0

I have a panel xib which is owned by class FooController. FooController also has outlets to the
panel’s Cancel and Proceed buttons.

I later decided to recycle this panel for use by the application delegate’s termination routine. When I assigned selectors to the buttons, I found that the Proceed/Save button and a programmatically added DontSave button could accept as selectors methods that were defined in the application delegate class. But the Cancel button would cause “unrecognized selector” errors unless its selector was defined in the owner class, FooController.

Fine, that seemed logical. To be consistent, I set up the Proceed/Save and DontSave selectors in the FooController class too. But then they would generate “unrecognized selector” errors.

So the Cancel button requires its selector to be in the FooController class. The Proceed/Save and DontSave buttons require their selectors to be in the appDelegate class. But all three buttons are explicitly owned by FooController; as you can see in the code below, even the added DontSave button is explicitly assigned to the FooController-owned panel’s contentView:

- (void) adviseOfPendingChangesBeforeQuit {

// Open the panel.
[NSBundle loadNibNamed:@"panelConfirmation" owner:self.fooController];

// Add an extra "Don't Save" button.
NSButton *btnDontSave = [[NSButton alloc] initWithFrame:NSMakeRect(12.0f, 12.0f, 106.0f, 32.0f)]; 
[btnDontSave setTitle:NSLocalizedString(@"Don't Save", @"Don't Save")];
[btnDontSave setButtonType:NSMomentaryPushInButton];
[btnDontSave setBezelStyle:NSRoundedBezelStyle];
[btnDontSave setAction:@selector(dumpChangesAndQuitPerPendingConfirmPanel)]; // method defined in this, the appDelegate class
NSView *viewToReceiveNewButton = [self.fooController.panelForInput contentView];
[viewToReceiveNewButton addSubview:btnDontSave];
[btnDontSave release];

// Change the “proceed” button’s title to "Save", make it the default, and assign its action.
[self.fooController.btnProceed setTitle:NSLocalizedString(@"Save", @"Save")];
[self.fooController.btnProceed setKeyEquivalent:@"\r"];
[self.fooController.btnProceed setAction:@selector(saveAndQuitPerPendingConfirmPanel)]; // method defined in this, the appDelegate class

// Assign “Cancel” button's action.
[self.fooController.btnCancel setAction:@selector(callCancelQuit)];

// Finish setting up the panel and launch it.
// ...
}

I have noticed before that typical Cancel functions tend to work automatically. For instance, the Escape key automatically calls any button you have titled “Cancel.” Maybe there’s similar behind-the-scenes machinery at work here. If so, I wish I understood better what’s going on. As it stands now, I’m worried that these crisscrossing selectors might break some day, even though they all work OK for now. The inconsistency is troubling.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:57:29+00:00Added an answer on May 27, 2026 at 3:57 am

    Actions should accept the sender as an argument. It should take the form:

    - (void)someActionName:(id)sender;
    

    Most of the standard calls work this way. If you want to use the same cancel mechanism the Escape key uses, use NSResponder’s -cancelOperation: (note the colon at the end – it’s the standard action-with-sender-as-the-sole-argument form).

    Also, I don’t see you setting targets for your buttons. The target-action mechanism means your button may have a target but should have an action. You’re setting the buttons’ actions but if you don’t set their target, they’re “nil-targeted”, which means Cocoa climbs the responder chain looking for the first object that responds to the selector you set in the action.

    This is the best I can tell you with the detail you provided. You’ll need to be a lot more specific about your architecture (class names, exact error messages, more code if any is missing, etc.) for more detailed answers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a panel on an aspx page which contains an UpdatePanel. This panel
i have a panel (A), which contains 3 other panels (AA, AB, AC). Each
I have a panel in my master page that has textboxes for users login.
I have a Panel on a Windows Form. The Panel has autoscroll enabled. The
I have panel which I colored blue if this panel is being selected (clicked
I have a panel containing a number of components, one of which is a
I have a panel that has lots of labels and checkboxes. I want to
I have a panel component on my flex application. This component has a click
I have a panel with several canvases and buttons on it. I want to
I have a panel of labels, buttons and image that I wish to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.