Getting button binding to invoke an action
Getting button binding to invoke an action
- Subject: Getting button binding to invoke an action
- From: Tron Thomas <email@hidden>
- Date: Sat, 08 Sep 2007 20:01:46 -0700
I am trying to understand how I can use Cocoa binding in my
application development.
As an experiment, I've created a Cocoa application. In the NIB file
I have instantiated an NSObjectController, and instance of a custom
class I want the controller to manipulate. I have connected the
class instance to the content outlet of the NSObjectController instance.
Next, I added an NSButton to the view in main window. I tried to
create a binding such that when the button is clicked, an action
would be called in my controlled class.
I have tried binding the target for the button to the selection of
the NSObjectController, and specifying the desired action in the
custom class as the selector.
When I run the application and click on the button, the program
crashes with a EXC_BAD_ACCESS signal the following stack trace:
#0 0x92bd7478 in +[NSInvocation newInvocationWithMethodSignature:]
#1 0x92c5f494 in +[NSInvocation invocationWithMethodSignature:]
#2 0x93c55dc4 in -[NSObject(_NSBinderKeyValueCodingAdditions)
_invokeSelector:withArguments:onKeyPath:]
#3 0x93c7e268 in -[NSObjectController
_invokeSingleSelector:withArguments:onKeyPath:]
#4 0x93c55d94 in -[NSObject(_NSBinderKeyValueCodingAdditions)
_invokeSelector:withArguments:onKeyPath:]
#5 0x93c61a60 in -[NSBinder
_invokeSelector:withArguments:onKeyPath:ofObject:mode:raisesForNotApplic
ableKeys:]
#6 0x93c62024 in -[NSBinder
invokeSelector:withArguments:forBinding:error:]
#7 0x93c81a24 in -[NSActionBinder
_invokeSelector:withArguments:forBinding:]
#8 0x93c82130 in -[NSActionBinder _executePerformAction]
#9 0x93c822f4 in -[NSActionBinder
_performActionWithCommitEditing:didCommit:contextInfo:]
#10 0x90a451f4 in objc_msgSendv
#11 0x92bdec94 in -[NSInvocation invoke]
#12 0x92bdf244 in -[NSInvocation invokeWithTarget:]
#13 0x93c590e4 in _NSSendCommitEditingSelector
#14 0x93c7c600 in -[NSController
_controllerEditor:didCommit:contextInfo:]
#15 0x90a451f4 in objc_msgSendv
#16 0x92bdec94 in -[NSInvocation invoke]
#17 0x92bdf244 in -[NSInvocation invokeWithTarget:]
#18 0x92bedc04 in __NSFireDelayedPerform
#19 0x907f1578 in __CFRunLoopDoTimer
#20 0x907ddef8 in __CFRunLoopRun
#21 0x907dd4ac in CFRunLoopRunSpecific
#22 0x9329bb20 in RunCurrentEventLoopInMode
#23 0x9329b12c in ReceiveNextEventCommon
#24 0x9329b020 in BlockUntilNextEventMatchingListInMode
#25 0x937a1ae4 in _DPSNextEvent
#26 0x937a17a8 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#27 0x9379dcec in -[NSApplication run]
#28 0x9388e87c in NSApplicationMain
#29 0x0000ef34 in main at main.mm:9
The action for the custom class has the standard signature: - (void)
actionName:(id)sender.
What is needed to get the button binding to successfully invoke the
desired action?
_______________________________________________
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