Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sundark

macrumors newbie
Original poster
Jun 20, 2010
9
0
i was trying to create outlets and actions in inspector window. The book says
1. select File Owner icon on the nib file
2. In the Inspector Window, under the Class Actions sections, click the plus (+) button,to add an action named btnClicked.

I can't seem to find the class actions section at all i the Inspector window - what am I doing wrong ?
 
I can't seem to find the class actions section at all i the Inspector window - what am I doing wrong ?

You have to have specified the methods (if that's what you mean by class actions) in Xcode before you go to Interface Builder.

To do so, in your interface/header file (.h), enter:

Code:
-(IBAction) btnClicked;
In your implementation file (.m), enter:

Code:
-(IBAction) btnClicked
{
  NSLog(@"It worked!");
}
Then save the above in Xcode. Then go to IB and the btnClicked method will show up when you click the plus (+) button, to add an action named btnClicked.

If that's not your question, or it still doesn't work, then throw away the book you're using, get a new book, and work through it following the instructions exactly.
 
Thanks.
Usually I define the outlets and actions in the view controller class and link them in the interface builder.
However, the book (Beginning iPhone SDK Programming by Wei Meng Lee), suggested that you can alternatively create outlets and actions in the Interfacebuilder and then generate the corresponding code in the classes by simply clicking the Generate Code menu option. It's the reverse of what we generally do.
I just was curious whether there was any setup issue with the xCode.
Thanks
Sundar

You have to have specified the methods (if that's what you mean by class actions) in Xcode before you go to Interface Builder.

To do so, in your interface/header file (.h), enter:

Code:
-(IBAction) btnClicked;
In your implementation file (.m), enter:

Code:
-(IBAction) btnClicked
{
  NSLog(@"It worked!");
}
Then save the above in Xcode. Then go to IB and the btnClicked method will show up when you click the plus (+) button, to add an action named btnClicked.

If that's not your question, or it still doesn't work, then throw away the book you're using, get a new book, and work through it following the instructions exactly.
 
Most developers these days update the text in their header files in the Xcode editor and make the connections between objects in IB. That's how I recommend that you work. However some developers in olden days used to add outlets and actions in IB and have them sent back to Xcode. I'm pretty sure you can still do that but I haven't tried it in a few years.

They moved the location of the viewer for outlets and actions in a recent version of IB so what you're seeing in IB probably has changed since the book was published. The outlets and actions are in the Library inspector. Click the Classes tab, choose the class that you want to view, and in the bottom pane choose Outlets or Actions from the popup menu. There's now a + button where you can add new outlets and actions. At the bottom of the window there's a gear popup menu that has an item to write class files. I haven't monkeyed around with any of that but the UI seems to still be there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.