FROM : John Brownlow
DATE : Tue Apr 12 00:20:56 2005
thanks, john. for some reason I didn't realize -awakeFromNIB was
generally available...
On Apr 11, 2005, at 4:48 PM, John C. Randolph wrote:
>
> On Apr 11, 2005, at 10:36 AM, John Brownlow wrote:
>
>> I have a main editor window which has several drawers. Each of these
>> drawers is quite complicated so I gave each one its own controller to
>> separate out the logic, although they are staying in the same NIB
>> because they are fundamentally connected.
>>
>> Just for my own personal ease I would rather instantiate these
>> controllers in the NIB so I can hook them up with IBOutlets etc. But
>> then the question becomes, how to initialize them.
>>
>> If I could rely on all the objects in the NIB being initialized when
>> they are created then they could initialize themselves, but I suspect
>> that is not how things work and so not all the objects they need will
>> be there when they are instantiated.
>>
>> The alternative is to put the initialization in the
>> mainEditorWindowController which loads the NIB, but that grates
>> because I feel the objects should self-initialize. What is good
>> practice here? Should I have a -NIBDidLoad method that the
>> windowController calls, or a notification, or what?
>
> In your -init method, perform whatever initialization you like that
> does *not* depend on any of your outlets being in place. If you need
> to perform initialization that does depend on the connections in the
> nib, then implement -awakeFromNib:
>
> - (void)awakeFromNib
>
> Prepares the receiver for service after it has been loaded from an
> Interface Builder archive, or nib file. An awakeFromNib message is
> sent to each object loaded from the archive, but only if it can
> respond to the message, and only after all the objects in the archive
> have been loaded and initialized. When an object receives an
> awakeFromNib message, it’s guaranteed to have all its outlet instance
> variables set.
>
>
> -jcr
>
>
> John C. Randolph <<email_removed>> (408) 974-8819
> Sr. Cocoa Software Engineer,
> Apple Worldwide Developer Relations
> http://developer.apple.com/cocoa/index.html
>
>
>
>
--
John Brownlow
Deep Fried Films, Inc
http://www.johnbrownlow.com
http://www.pinkheadedbug.com
DATE : Tue Apr 12 00:20:56 2005
thanks, john. for some reason I didn't realize -awakeFromNIB was
generally available...
On Apr 11, 2005, at 4:48 PM, John C. Randolph wrote:
>
> On Apr 11, 2005, at 10:36 AM, John Brownlow wrote:
>
>> I have a main editor window which has several drawers. Each of these
>> drawers is quite complicated so I gave each one its own controller to
>> separate out the logic, although they are staying in the same NIB
>> because they are fundamentally connected.
>>
>> Just for my own personal ease I would rather instantiate these
>> controllers in the NIB so I can hook them up with IBOutlets etc. But
>> then the question becomes, how to initialize them.
>>
>> If I could rely on all the objects in the NIB being initialized when
>> they are created then they could initialize themselves, but I suspect
>> that is not how things work and so not all the objects they need will
>> be there when they are instantiated.
>>
>> The alternative is to put the initialization in the
>> mainEditorWindowController which loads the NIB, but that grates
>> because I feel the objects should self-initialize. What is good
>> practice here? Should I have a -NIBDidLoad method that the
>> windowController calls, or a notification, or what?
>
> In your -init method, perform whatever initialization you like that
> does *not* depend on any of your outlets being in place. If you need
> to perform initialization that does depend on the connections in the
> nib, then implement -awakeFromNib:
>
> - (void)awakeFromNib
>
> Prepares the receiver for service after it has been loaded from an
> Interface Builder archive, or nib file. An awakeFromNib message is
> sent to each object loaded from the archive, but only if it can
> respond to the message, and only after all the objects in the archive
> have been loaded and initialized. When an object receives an
> awakeFromNib message, it’s guaranteed to have all its outlet instance
> variables set.
>
>
> -jcr
>
>
> John C. Randolph <<email_removed>> (408) 974-8819
> Sr. Cocoa Software Engineer,
> Apple Worldwide Developer Relations
> http://developer.apple.com/cocoa/index.html
>
>
>
>
--
John Brownlow
Deep Fried Films, Inc
http://www.johnbrownlow.com
http://www.pinkheadedbug.com
| Related mails | Author | Date |
|---|---|---|
| John Brownlow | Apr 11, 19:36 | |
| Scott Stevenson | Apr 11, 20:02 | |
| John C. Randolph | Apr 11, 22:48 | |
| John Brownlow | Apr 12, 00:20 | |
| John Brownlow | Apr 12, 16:11 | |
| mmalcolm crawford | Apr 12, 16:46 | |
| John Brownlow | Apr 12, 20:46 | |
| mmalcolm crawford | Apr 12, 23:51 | |
| John Brownlow | Apr 13, 00:02 | |
| mmalcolm crawford | Apr 13, 00:11 | |
| John Brownlow | Apr 13, 00:48 | |
| mmalcolm crawford | Apr 13, 01:42 |






Cocoa mail archive

