Re: IB Palettes?
Re: IB Palettes?
- Subject: Re: IB Palettes?
- From: Jon Hess <email@hidden>
- Date: Thu, 22 Nov 2007 23:05:08 -0800
On Nov 22, 2007, at 1:32 PM, Rick Mann <email@hidden> wrote:
On Nov 22, 2007, at 1:16 PM, Jonathan Hess wrote:
In Interface Builder you can specify that any instance can be of a
different more derived type at runtime. To do this use the identity
inspector (command + 6) and use the custom class combo box to type
in a new class name. At runtime, an instance of that class will be
instantiated in place of the selected object.
So, if you subclassed NSView, drag an NSCustomView to your
document. If you subclassed something more specific like an
NSButton, drag an NSButton to your document. Once you've done that
select the instance and use the identity inspector to change the
class to your custom subclass. When you load your nib at runtime an
instance of your custom class will be instantiated instead of the
button.
Thanks.
So, that's the second technique described by "View Programming Guide
for Cocoa." It says:
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.
Hey Rick -
Your view will get the initWithCoder: message when it has been
integrated into a document by means of a plugin. It will also get the
initWithCoder: message if you use the custom class inspector method
with anything other than NSCustomView. If you use NSCustomView you'll
get initEithFrame:.
From my iPhone -
Jon Hess
--
Rick
_______________________________________________
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