• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: First-Time Help Needed: Instantiating a Subclass in IB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: First-Time Help Needed: Instantiating a Subclass in IB


  • Subject: Re: First-Time Help Needed: Instantiating a Subclass in IB
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 14 Oct 2005 23:12:01 -0400

On Oct 14, 2005, at 10:34 PM, Jerry Krinock wrote:

Ok, so I find a white rectangle that looks like an NSTextField, with a
tooltip that says "NSTextField", drag and drop it into my window.


Choose Tools > Show Info, choose Custom Class from the menu ...
select your class from the list, and double-click ...


OK, I did that. Now I see in my nib's main document window, Instances tab,
list view, that this field is a "MyTextField". Looks cool.


My problem: At run-time, my subclass' -initWithFrame method doesn't run for
this field.

It's not supposed to. From "What Happens When a NIB File is Loaded":

"When you drag a standard object into the design window, Interface Builder encodes the actual class for that object, initializing the object as it builds the nib file. For custom subclasses of such objects, Interface Builder encodes the standard object but tells the archiver to swap in your custom class when the object is unarchived. These objects are also initialized when the nib file is built. Therefore, when the nib file is loaded, initWithFrame: is not called for either standard objects or custom subclasses of standard objects.
...
Therefore, if you create a custom subclass of NSView, add a Custom View object to your design window, and assign your custom subclass to that object, your initWithFrame: method will be called when the nib is loaded. For all other objects, whether standard Interface Builder objects or custom subclasses of standard objects, initWithFrame: is never called.


If you need to initialize a standard Interface Builder object (or a custom subclass of such an object) after its nib file has been loaded, create an awakeFromNib method for the object. ..."

Found here:

<http://tinyurl.com/9ksjz>
<http://developer.apple.com/documentation/Cocoa/Conceptual/ LoadingResources/Concepts/NibFileLoaded.html>


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >First-Time Help Needed: Instantiating a Subclass in IB (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: First-Time Help Needed: Instantiating a Subclass in IB
  • Next by Date: Re: Drag image of NSView
  • Previous by thread: First-Time Help Needed: Instantiating a Subclass in IB
  • Next by thread: Re: First-Time Help Needed: Instantiating a Subclass in IB
  • Index(es):
    • Date
    • Thread