Re: awakeFromNib and sheets
Re: awakeFromNib and sheets
- Subject: Re: awakeFromNib and sheets
- From: Mark T <email@hidden>
- Date: Fri, 24 Aug 2001 21:12:48 -0400
awakeFromNib is really more for setting up your application following
unarchiving, than *doing* things, like opening sheets, or at least
that's my take on it. I think that what you're looking for here is
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
which you implement in NSApp's delegate. The sheet should open
correctly if you tell it to there.
Mark T.
Hi folks,
I had an unexpected problem with an NSBeginAlertSheet today related
to the awakeFromNib method. My understanding was that awakeFromNib
is called only once your applications nib file has been un-archived.
I had assumed 'un-archived' meant that items such as windows from
within the nib were ready to work with... However, I added an
NSBeginAlertSheet as part of an error checking routine in my
awakeFromNib method only to find that the sheet not only popped open
in the wrong place but before the window it was attached to. Then,
to add insult to injury, it is then mostly obscured by the window it
should have been attached to the front of in the first place :o)
I've fixed the issue with what I think is a messy work-around
(setting a instance variable error flag then using a
windowDidBecomeKey delegate to trigger the sheet) but I wondered if
I've made a basic incorrect assumption about awakeFromNibs.
My feeling now is that the awakeFromNib method is called for each
item individually within the nib, one by one, as they are
un-archived. So any one item within the nib should really check
before interacting with any other items within it's parent nib.
Any hints?
A second issue I bumped into was similar to a list thread here a few
days back. My above alert sheet has a default "Quit" and a "Try
Again" option, where the "Try Again" re-tests the error condition
and then re-opens another sheet if the problem is still there. To my
surprise, user acknowledgment of a sheet does not immediately cause
it sheet to close. In fact the 2nd sheet opens on top of the
previous sheet before the first sheet decides to fold its self away.
Again I've fixed this issue with a less than elegant solution (set
up a timer with a delay of 1 second that test for the error
condition and if needed opens another error sheet).
Any hints?
Regards,
Gary