Re: Initializing an NSView derivative's variables...
Re: Initializing an NSView derivative's variables...
- Subject: Re: Initializing an NSView derivative's variables...
- From: Roarke Lynch <email@hidden>
- Date: Tue, 19 Aug 2003 01:11:36 -0400
On Sunday, August 18, 2002, at 02:16 AM, Jiva DeVoe wrote:
So I have a custom view that I have attached to a custom view object in
IB.
When the window is shown, my "initWithFrame" method will get called,
right?
But what I really want to do is something like "initWithObjectForView"
and
init the view with the object I want it to draw. This paradigm seems
to be
something I whack my head into over and over, and it doesn't seem to fit
with the Cocoa framework. What am I missing? What is the design
pattern
behind a custom view and initializing the object the view needs to
show?
How do others accomplish this same kind of thing? Do they write a
"setObject" method to set the object for the view? And if so, when do
they
call it?
There are a bunch of ways you could do it. You could add an outlet
to your custom view, and in the view's awakeFromNib method have it call
the outlet to set the object. You could do a similar thing with the Nibs
NSOwner, but it reverse (i.e. have owner or another object call your
view's setObject method in it's awakeFromNib etc...) If the nib is you
Main nib, you could set an App Delegate and have this set the object
from the applicationDidFinishLaunching notification, and so on and so
forth. I guess you could also simply not instantiate the object in IB
and call your own init method with another object.
Roarke Lynch
------------------
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.