First, my warning--this is a newbie question.
I have a question about NSButton and Action Invocation binding. So, I have a simple Cocoa (Not a Document) app. It takes two values, eccentricity and eccentricAnomaly and uses these values in an instance method createMeanAnomalyWithEccentricty:andEccentricAnomaly: to calculate meanAnomaly.
So, here's the code:
MeanAnomaly.h MeanAnomaly.m #import <Cocoa/Cocoa.h> #import "MeanAnomaly.h" #import <math.h>
@implementation MeanAnomaly .
. . - (float) calculateMeanAnomalyWithEccentricity:(float)eccentricityNumber andEccentricAnomaly:(float)eccentricAnomalyNumber { meanAnomaly = eccentricityNumber * sin(eccentricAnomalyNumber); return meanAnomaly; } .
. . @end
The interface has three text fields, one for each value. I have an NSObjectController, called MeanAnomalyController, which has a Class Object name of "MeanAnomaly". It is "connected" to and instance of MeanAnomaly in the MainMenu.nib. Using Cocoa Bindings, I have the fields bound to their keys,
eccentricity eccentricAnomaly meanAnomaly
and for the "Calculate!" NSButton, I used target-argument binding,
target-- Bind To: MeanAnomalyController Controller Key: selection Model Key Path: (left blank) Selector: calculateMeanAnomalyWithEccentricity:andEccentricAnomaly:
and the arguments (2) are
argument-- Bind To: MeanAnomalyController Controller Key: selection Model Key Path: eccentricAnomaly Selector: calculateMeanAnomalyWithEccentricity:andEccentricAnomaly:
argument 2-- Bind To: MeanAnomalyController Controller Key: selection Model Key Path: eccentricity Selector: calculateMeanAnomalyWithEccentricity:andEccentricAnomaly: Building goes fine. Upon Run, I can enter info into the fields, but pressing "Calculate!" does nothing. I know I'm doing something bone-headed here, but just can't figure this out.
Thanks.
Jim Hillhouse |