FROM : Ricky Sharp
DATE : Fri Nov 23 04:04:56 2007
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_removed>
Instant Interactive(tm) http://www.instantinteractive.com
DATE : Fri Nov 23 04:04:56 2007
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_removed>
Instant Interactive(tm) http://www.instantinteractive.com
| Related mails | Author | Date |
|---|---|---|
| Rick Mann | Nov 22, 20:25 | |
| Jonathan Hess | Nov 22, 22:16 | |
| Rick Mann | Nov 22, 22:32 | |
| Ricky Sharp | Nov 23, 04:04 | |
| Jon Hess | Nov 23, 08:05 |






Cocoa mail archive

