• 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: IB Palettes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IB Palettes?


  • Subject: Re: IB Palettes?
  • From: Ricky Sharp <email@hidden>
  • Date: Thu, 22 Nov 2007 21:04:56 -0600


On Nov 22, 2007, at 3:32 PM, Rick Mann wrote:


On Nov 22, 2007, at 1:16 PM, Jonathan Hess wrote:

The second technique is to specify a custom class is used when your custom view subclass inherits
from a view that Interface Builder provides support for directly. For example, you can create an
NSScrollView instance in Interface Builder and specify that a custom subclass (MyScrollView) should
be used instead, again using the inspector. In this case, when the nib file is loaded by the application,
the view instance has already been created and the MyScrollView implementation of initWithFrame:
is never called. The MyScrollView instance receives an awakeFromNib message and can configure
itself accordingly.

The problem here is that, I don't see how my initWithFrame: could ever get called. IB needs to call that before archiving the view, and it doesn't have the ability to call it.


Even if I had a custom palette for it, I don't see how it could call it, but the phrase "If you have not created an Interface Builder palette" implies that there is a way to create a palette.

I strongly suggest reading up on the docs for initWithFrame for when it will be called. Also, check out my IB Plug-In sample code (I posted a link to that to this list and xcode-users). Part of the sample sprinkles in some NSLog statements to make it easy to understand what methods IB calls at various points.


The short of it...

If you have a custom plug-in, IB will call initWithFrame: for those views that are contained within the plug-in library's nib. When you drag an item off of the library, encodeWithCoder: is called against the instance. Then, when it's dropped into say a window, initWithCoder: is called using the encoded data. Finally, when the nib is saved, encodeWithCoder: is used to archive all your view's data.

When you then run your app, all your custom views will be 'init'd' with initWithCoder:. If you ever want to programatically create instances of your view, you'd then call either initWithFrame: or whatever designated initializer.

So you can see that depending upon what you're doing, either initWithFrame: _or_ initWithCoder: will be used to initialize your instances.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >IB Palettes? (From: Rick Mann <email@hidden>)
 >Re: IB Palettes? (From: Jonathan Hess <email@hidden>)
 >Re: IB Palettes? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Auxiliary Data in custom view?
  • Next by Date: Overlapping Views
  • Previous by thread: Re: IB Palettes?
  • Next by thread: Re: IB Palettes?
  • Index(es):
    • Date
    • Thread