RSS

Instantiating an Object in Interface Builder on Leopard

If you’re like me, you’ve began the transition to coding on Leopard. After giving XCode and IB a swirl, you’re going to want to get down to coding real stuff. After starting a new project and creating a a few classes in XCode you want to instantiate your controller object. When you open up Interface Builder, you go to the menu bar and try to find Instantiate Object. You won’t find it. This took me awhile to figure out. Where the hell did Apple put this? I want to instantiate my controller object. I can’t find out how. I finally did find it, and when a friend of mine asked me the same question about IB, I decided to write up this post to quickly explain it.

Apple has done away with the old way of instantiating classes completely. Now what you have to do is open your Library panel (cmd-shift-L). In the search box type NSObject. This will reveal two possible items. Drag the “Object” one into your project window.

Selecting NSObject

You’ll then want to reveal the inspector on this object. Click the Object in your project and open the Inspector (cmd-shift-I). Select the second to right tab called Identity (circle with an “i” in it). Under Class Identity choose the class you want to instantiate.

Class Identity

You’ve now got your object instantiated in Interface Builder. Just a little reminder: You might need to synch IB with XCode to see your updated class files. Do this by going to File | Synchronize with XCode.

That’s all for this little tip. I hope this saved you a little frustration in the transition from Tiger to Leopard. If you have any other little tips about the transition, I would love to hear them. Please feel free to post in the comments.

  • Ben
    Thanks for this article, without it i would have given it up.
    thanks :)
  • Adam
    Thanks!
  • SepSmoolo
    I am necessary wish to find
  • Good post. This was far from obvious in XCode 3!
  • cynik
    Yeah, cheers. I actually did what this article says, before finding it, but until I read it I was still unsure if I had guessed right. Xcode 3 is very fucking far from intuitive.
  • Dustyn
    Holy crap. I just started trying to learn this and the book looked nothing like it. I was gonna give up n it. Thanks
  • Thank you for putting this together. I was at a loss without this information and now I can get back to learning Cocoa programming.
  • Nuri Hassim
    Many thanks for the tip. I was going nuts trying to find this option
blog comments powered by Disqus
« Update From The Ashes | Cocoa Code Snippet: Simple Window Fade In/Out »