don't see class action in inspector window

Discussion in 'iOS Programming' started by sundark, Jun 20, 2010.

  1. sundark macrumors newbie

    Joined:
    Jun 20, 2010
    #1
    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 ?
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Which book (end edition)?

    Which version of Xcode/IB?
     
  3. PatrickCocoa macrumors 6502a

    Joined:
    Dec 2, 2008
    #3
    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.
     
  4. sundark thread starter macrumors newbie

    Joined:
    Jun 20, 2010
    #4
    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

     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    From the Release Notes for Interface Builder 3.2:
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    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.
     

Share This Page