document loading / startup problems
document loading / startup problems
- Subject: document loading / startup problems
- From: "Simon Stapleton" <email@hidden>
- Date: Tue, 03 Jul 2001 10:54:02 +0100
Another newbie question.
I'm having some interesting issues with startup (and load-from-file)
behaviour.
This is a document based app, and much of the logic has been ripped
wholesale from the vermont recipes site (for which many thanks are in
order - it's helped immensely with my understanding of what goes on and
what _needs_ to go on)
The behaviour I'm seeing is this: Whenever I fire up the app, or ask it
to load a file, all the data fields in the main window come up blank. I
know the stuff written to file is being done correctly, as I can see the
information in the file.
I've run it through the debugger, and this is what's happening on a 'cold
start' - much of the same happens on loading the file:
1 - Document object comes up and runs through its -init: method. This
allocates and initialises my model.
2 - Initialisation of the model goes off to NSUserDefaults and sets
itself up. I can see this working through the debugger, and all state for
the object is correctly set up. As the model sets itself up, it posts
notification events for all the fields its initialising. Of course, my
app hasn't registered for these yet, so they disappear off into the
aether.
3 - Now the document runs its -makeWindowControllers: method, which
creates a single window controller (the other window controllers will be
created 'lazily' in response to button clicks).
4 - The windowcontroller runs its -initWithWindowNibName: method.
5 - The window comes up. This sends a bunch of messages to update the
values of the model to be the values of the fields in the nib. These get
passed on to the model, which updates its fields to the _empty_ values
from the nib (and a bunch more notifications get passed on, to be
ignored, as I still haven't registered for them)
6 - Now the windowcontroller runs its -windowDidLoad: method, which
registers for notifications and forces its outlets to get updated to the
model values.
It seems to me that I should either be
a - deferring the initialisation of the model object until later (between
steps 5 and 6 would seem the only place that would be possible, as the
model needs to be there for the windowcontroller to register interest in
its notifications)
or
b - The update messages from step 5 shouldn't be being picked up. I may
have messed something up in the nib file (I know I had the owner set to
the document at one point, maybe they're being sent direct to the
document rather than the windowcontroller). If the window controller is
still in the process of being initialised, can it still respond and
forward messages?
I suspect that it's 'b' that's what's going on. Unless I've missed
something fundamental, which is entirely possible.
So. Any hints / tips / pointers / flames would be appreciated.
Although this is a somewhat frustrating problem (I spent 4 hours last
night trying to work out what's going on), I'm becoming more and more
enamoured with cocoa. It rocks.
Simon
--
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/