Re: document loading / startup problems (Cracked it!)
Re: document loading / startup problems (Cracked it!)
- Subject: Re: document loading / startup problems (Cracked it!)
- From: "Simon Stapleton" <email@hidden>
- Date: Wed, 04 Jul 2001 13:15:15 +0100
Quoting Michael Dagate <email@hidden>:
>
>
On Tuesday, July 3, 2001, at 06:41 PM, Simon Stapleton wrote:
>
>
> Hi.
>
>
>
> I'm doing this - the problem seems to be that the model is
>
getting
>
> initialised before the window comes up, either from the defaults
>
for an
>
> 'untitled' document, or through the
>
loadDataRepresentation:ofType:
>
> method.
>
>
Okay, this sounds fine so far.
>
>
>
> As the window comes up, after this has happened, it's generating
>
>
> actions which end up (through the windowcontroller action
>
methods)
>
> going off to the model and zapping all my carefully initialised
>
data to
>
> whatever happens to be in the nib (nothing).
>
>
>
This sounds strange. I don't know why or how you could be
>
generating
>
action method calls without user activity. Have you inadvertently
>
instantiated your window controller object in the nib file? Make
>
it the
>
owner of the nib, but don't instantiate it in the nib file.
>
Instantiating it archives a real object in the nib file that gets
>
recreated in memory whenever the nib file is read. Perhaps this is
>
>
causing your data model to get updated to match a window
>
controller
>
object that has been unarchived from the nib file.
I thought this might be the case, too, but it wasn't.
What appears to have been happening is this:
Waking up the nib sends an action message, but the sender is nil. So
(and in order to get my undo/redo stuff working properly) I have
something like this in my action messages...
- myAction: (id) sender {
if (sender != nil && ![[sender stringValue] isEqualToString:[[self
myModel] getValue]]) {
// do the update stuff
}
}
...Which seems to work.
It's still a mystery as to why I'm getting the dummy actions (I thought
it was because my actions were called 'setThing' and they were being
interpreted as outlets, but even when I set them to 'setThingAction' I
got the same behaviour), but I'm willing to accept it as 'just one of
those things that happens' and leave it at that[1].
Whatever, it all works laaaaaaavley now.
Simon
[1] Gracious of me, I know ;-)
--
Your mouse has moved. You must reboot Windows NT for these changes to be
recognised.
This message was sent by Easymail -
http://www.easynet.co.uk/