1

I'm following along on this tutorial with Xcode 4. The tutorial is for Xcode 3, with Interface Builder, and Xcode has changed since then.

The step I'm on:

diagram of Xcode 3 step
(source: cocoalab.com)

In the palette, in the Action section, click the Add (+) button to add an action (i.e., an action method) to the MFAExampleClass class. Replace the default name provided by Interface Builder by a more meaningful name (for example, you can enter "setTo5:" because we will program this method to display the number 5 in the text field). Add another method, and give it a name (for example "reset:", because we will program it to display the number 0 in the text field). Note that our method names both end with a colon (":"). More about this later.

I've looked through menu items that could be what the "class library" pane, but I can't find it. Does anyone know where it is? Or do I have to accomplish this in a different way then the tutorial describes?

Running Xcode 4.6.3, on Mac OS X 10.8.4.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Eliza Wilson
  • 1,031
  • 1
  • 13
  • 38
  • 1
    Just add the method to the class interface and implementation manually. It should have the signature `-(IBAction)setTo5:(id)sender`. – Kevin Aug 03 '13 at 15:30
  • @Kevin So I just type that into the interface and implementation, and I'm good? – Eliza Wilson Aug 03 '13 at 15:34
  • Yes, but you'll need to follow it with a `;` in the interface and `{}` in the implementation (until you fill in the code there). If you scroll down a bit in the tutorial you'll see the code. – Kevin Aug 03 '13 at 15:39
  • @Kevin: make that a answer and I'll accept. :) – Eliza Wilson Aug 03 '13 at 15:43

2 Answers2

1

That button just adds a stub method to your class. You can add it manually:

@interface MFAExampleClass : NSObject
...
-(IBAction)setTo5:(id)sender;
@end

and

@implementation MFAExampleClass
...
-(IBAction)setTo5:(id)sender
{
    // Action code here
}
@end
Kevin
  • 53,822
  • 15
  • 101
  • 132
1

You can open up an assistant window fr the header file next to the nib, and opt-drag a button to create IBOutlet or IBAction

Rob van der Veer
  • 1,148
  • 1
  • 7
  • 20