• 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
Using NSButton and Action Invocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSButton and Action Invocation


  • Subject: Using NSButton and Action Invocation
  • From: James Hillhouse <email@hidden>
  • Date: Thu, 23 Jun 2005 18:37:09 -0500

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
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: DragNDropOutlineView Example Define Syntax
  • Next by Date: Re: Error Message with Core Data/Bindings
  • Previous by thread: Re: DragNDropOutlineView Example Define Syntax
  • Next by thread: Parent entities
  • Index(es):
    • Date
    • Thread