Mac Plz help me to fix a bug.


macrumors newbie
Original poster
Jul 5, 2005
Hi Folks, I just followed to the tutorial of Apple, and I got an error that
"/ConverterController.m:12: error: 'converter' undeclared (first use in this function)" Can anyone help me?

#import <Cocoa/Cocoa.h>

@interface Converter : NSObject

- (float)convertAmount:(float)amt atRate:(float)rate;

#import "Converter.h"

@implementation Converter

- (float)convertAmount:(float)amt atRate:(float)rate;
return (amt * rate);


#import <Cocoa/Cocoa.h>

@interface ConverterController : NSObject
IBOutlet NSTextField *dollarField;
IBOutlet NSTextField *rateField;
IBOutlet NSTextField *totalField;
- (IBAction)convert:(id)sender;

#import "ConverterController.h"
#import "Converter.h"

@implementation ConverterController

- (IBAction)convert:(id)sender
float rate, amt, total;
amt = [dollarField floatValue];
rate = [rateField floatValue];

total = [converter convertAmount:amt atRate:rate];

[totalField setFloatValue:total];
[rateField selectText:self];

- (void)awakeFromNib
[[rateField window] makeKeyAndOrderFront:self];
[rateField selectText:self];



macrumors 601
Mar 20, 2005
Put the [CODE ] and [/CODE ] tags around your code (without the space after each code in my example) and it will not create the smiley expressions and therefore be easier to read.


Staff member
Feb 5, 2004
New Zealand
You need to add an outlet called "converter" to the ConverterController class in Interface Builder, and connect it to the Converter object that you instantiated. From the tutorial:

ConverterController needs to access the text fields of the interface, so you’ve just provided outlets for that purpose. But ConverterController must also communicate with the Converter class (yet to be defined). To enable this communication, add an outlet named converter to ConverterController.
While connecting ConverterController’s outlets, you probably noticed that one outlet remains unconnected: converter. This outlet identifies an instance of the Converter class in the Currency Converter application, but this instance doesn’t exist yet.

Define the Converter class. This should be pretty easy because Converter, as you might recall, is a model class within the Model-View-Controller paradigm. Since instances of this type of class don’t communicate directly with the interface, there is no need for outlets or actions. Here are the steps to be completed:

  1. In the Classes display, make Converter a subclass of NSObject.
  2. Instantiate the Converter class.
  3. Make an outlet connection between ConverterController and Converter. Hint: Control-drag from the ConverterController instance to the Converter instance.
  4. Save MainMenu.nib.
You'll also need to add the following code to ConverterController.h under the text field declarations:

IBOutlet id converter;