• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unrecognized Selector Exception from IBAction's?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unrecognized Selector Exception from IBAction's?


  • Subject: Re: Unrecognized Selector Exception from IBAction's?
  • From: David Durkee <email@hidden>
  • Date: Thu, 03 Sep 2015 08:18:01 -0500

It looks like the buttons may be hooked up to an object of the wrong class? Your actions aren’t defined in NSConcreteHashTable. Check your connections.

David

> On Sep 3, 2015, at 7:09 AM, Dave <email@hidden> wrote:
>
> Hi,
>
> This is a Mac Project.
>
> I’m getting an Unrecognized Selector Exceptions when clicking on a Button Control:
>
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable leftButtonAction:]: unrecognized selector sent to instance 0x6000001221c0
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable leftRightAction:]: unrecognized selector sent to instance 0x6000001221c0
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable toggleDisclosureAction:]: unrecognized selector sent to instance 0x6000001221c0
>
> I’ve checked in IB and the controls in question seem to be wired up correctly.
>
> The way this works is that I have a WindowController that has a NIB file which contains a View Hierarchy. The WindowController then creates an Instance of a View Controller (LTWDetailViewController) and adds its View to a StackView which is inside a Scroll View. The View Outlets seem to be wired up ok, but the IBAction’s cause an Exception.
>
> Please see the following code:
>
> LTWDisclosureViewController.h
>
> @interface LTWDisclosureViewController : NSViewController
> {
> NSView*					_disclosedView;
> BOOL					_disclosureIsClosed;
> }
>
> @property (nonatomic,weak) IBOutlet NSTextField*					titleTextField;
> @property (nonatomic,weak) IBOutlet NSButton*						disclosureButton;
> @property (nonatomic,weak) IBOutlet NSView*						headerView;
>
>
> -(IBAction) toggleDisclosureAction:(id) theSender;							//***** Causes Exception when Clicked (the methods are defined in the corresponding .m file).
>
> @end
>
> ——————————————————————————————————————————————
> LTWDetailViewController.h
>
> @interface LTWDetailViewController : LTWDisclosureViewController
> {
> }
>
> -(id) initWithWindowKind:(NSString*) theWindowKind;
> -(NSView*) startup;
>
> @property (nonatomic,weak)	IBOutlet NSView*						pDetailView;
>
>
> -(IBAction) leftButtonAction:(id) theSender;							//***** Causes Exception when Clicked (the methods are defined in the corresponding .m file).
> -(IBAction) rightButtonAction:(id) theSender;							//***** Causes Exception when Clicked (the methods are defined in the corresponding .m file).
>
> @end
>
>
>
>
> ——————————————————————————————————————————————
>
> This code is in the Window Controller, setupStackView is called from awakeFromNib.
>
> -(void) setupStackView
> {
> CGFloat							myMinunumWidth;
> NSView*							myDetailView;
> BOOL							myClipStackViewHorizFlag;
> NSMutableDictionary*			myViewsDictionary;
> NSNotificationCenter*			myNotificationCenter;
> LTWDetailViewController*		myValidationDetailViewController;
>
> myNotificationCenter = [NSNotificationCenter defaultCenter];
>
> myValidationDetailViewController = [[LTWDetailViewController alloc] initWithWindowKind:@"Validation"];
>
> [myValidationDetailViewController setTitle:@"***** Test Title 1 *****"];
> myDetailView = myValidationDetailViewController.view;
>
>
> [self.pValidationListStackView addView:myDetailView inGravity:NSStackViewGravityTop];
>
> //**
> //**	Use the size of this view as an Minimum
> //**
> myMinunumWidth = myDetailView.frame.size.width;
>
> //**
> //**	Vertically Centered Stack
> //**
> self.pValidationListStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
> self.pValidationListStackView.alignment = NSLayoutAttributeTop;
> self.pValidationListStackView.spacing = 0;
>
> //**
> //**	Do Not Hug Horizontally - Let the Fixed Width Subviews Float Centrally
> //**
> [self.pValidationListStackView setHuggingPriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
>
> //**
> //**	Allow StackView Clipping
> //**
> myClipStackViewHorizFlag = YES;
>
> //**
> //**	Do Not Resist clipping Horizontally
> //**
> //**	NSScrollView Wrapper Will Allow the Clipped View to be Scrolled into View.
> //**
> if (myClipStackViewHorizFlag == YES)
> 	[self.pValidationListStackView setClippingResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
>
> //**
> //**	The StackView Min Width Will Match the SubView Minimum Width
> //**
> else
> 	[self.pValidationListStackView setClippingResistancePriority:NSLayoutPriorityDefaultHigh forOrientation:NSLayoutConstraintOrientationHorizontal];
>
> //**
> //**	Hug vertically
> //**
> [self.pValidationListStackView setHuggingPriority:NSLayoutPriorityDefaultHigh forOrientation:NSLayoutConstraintOrientationVertical];
>
> //**
> //**	Do Not Resist Clipping Vertically
> //**
> [self.pValidationListStackView setClippingResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationVertical];
>
> self.pValidationIssueScrollView.translatesAutoresizingMaskIntoConstraints = NO;
> NSAssert(self.pValidationIssueScrollView.contentView.isFlipped,@"ScrollView Clip View must be flipped?");
>
>
> //**
> //**	Add stack view to the scrollview
> //**
> [self.pValidationIssueScrollView setDocumentView:self.pValidationListStackView];
>
> //**
> //**	the StackView Width is Constrained to Match the ScrollView Width.
> //**
> //**	Note: this arrangement will not not show the horizontal scroller when clippng as the stackview width matches the scrollvew width.
> //**	to show the horiz scroller remove these constraints when the view size hits the minWidth limit.
> //**
> myViewsDictionary = [[NSMutableDictionary alloc] init];
> [myViewsDictionary setObject:self.pValidationListStackView forKey:@"stackView"];
>
> self.stackViewConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[stackView]-0-|" options:0 metrics:nil views:myViewsDictionary];
> [self.pValidationIssueScrollView addConstraints:self.stackViewConstraints];
> self.horizontalConstraintsApplied = YES;
>
> if (myClipStackViewHorizFlag == YES)
> 	{
>
> //**
> //**	Observe the scroll view frame and update the horizontal constraint as required
> //**
> 	self.frameObserver = [myNotificationCenter addObserverForName:NSViewFrameDidChangeNotification
> 													       object:self.pValidationIssueScrollView queue:nil
> 												       usingBlock:^(NSNotification*	theNotification)
> 		{
> 		if (self.pValidationIssueScrollView.frame.size.width < myMinunumWidth)
> 			{
> 			if (self.horizontalConstraintsApplied == YES)
> 				{
> 				[self.pValidationIssueScrollView removeConstraints:self.stackViewConstraints];
> 				self.horizontalConstraintsApplied = NO;
> 				}
>
> 			}
> 		else
> 			{
> 			if (!self.horizontalConstraintsApplied)
> 				{
> 				[self.pValidationIssueScrollView addConstraints:self.stackViewConstraints];
> 				self.horizontalConstraintsApplied = YES;
> 				}
> 		}
> 	}];
> 	}
> }
>
>
> //*****************************************************************************************
> //**
> //**	initWithWindowKind:
> //**
> //*****************************************************************************************
> -(instancetype) initWithWindowKind:(NSString*) theWindowKind
> {
> NSString*						myNIBName;
>
> myNIBName = @"ValidationWindow";
> self = [super initWithWindowNibName:myNIBName];
> if (self == nil)
> 	return nil;
>
> return self;
> }
>
>
> //*****************************************************************************************
> //**
> //**	awakeFromNib
> //**
> //*****************************************************************************************
> -(void) awakeFromNib
> {
> [self validationSetupStackView];
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Unrecognized Selector Exception from IBAction's?
      • From: Dave <email@hidden>
References: 
 >Unrecognized Selector Exception from IBAction's? (From: Dave <email@hidden>)

  • Prev by Date: Autolayout and Scroll Views?
  • Next by Date: Swift generics, circular type declarations, and segfaults, oh my!
  • Previous by thread: Re: Unrecognized Selector Exception from IBAction's?
  • Next by thread: Re: Unrecognized Selector Exception from IBAction's?
  • Index(es):
    • Date
    • Thread