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 protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]