Document object talking to main application object
Document object talking to main application object
- Subject: Document object talking to main application object
- From: Aaron Braunstein <email@hidden>
- Date: Fri, 30 Jul 2004 17:02:13 -0500
OK... I've tried a couple of different ways of getting this working
and neither of them is giving me any joy, so I thought I'd run it by
the (far more experienced) denizens of this list. It's a simple thing
really, but there's some kind of conceptual block on my end preventing
things from working properly. Any help working towards a solution
would be much appreciated.
The basic setup is this: I've got a preference controller object which
manages a preference window and holds the application defaults. This
preference object is spawned during the init: of a general application
controller instance associated with the main menu nib. I have need for
an NSDocument in the application be able to query the preference object
so that it can set/reset defaults as necessary.
So my problem seems to be: "How does the document object know how to
get in touch with the preference object?" I've tried two main methods,
neither of which work. The first - likely arising from a stubborn
clinging to old (i.e. pre-Cocoa) methods was to set up an extern
containing the pointer to the preference object. The second was to set
up an IBOutlet in my document class to point to the File's Owner object
of the preference's nib object.
As close to success as I can come is that the document is able to call
into the preference object... but unfortunately it's the wrong instance
(imagine my surprise when I discovered that there was more than one!)
I only ever instantiate one - via the standard [[PreferenceController
alloc] init] scheme in the application controller and nowhere else...
so I'm presuming that this second phantom/empty PreferenceController
object that my document is seeing is somehow an artifact of my setting
up the IBOutlet - which implies that either that approach is the wrong
one or I'm somehow doing it improperly.
The extern attempt involved putting an "extern PreferenceController
*prefController;" in my application controller's .h file followed by
the assignment thereof in its .m file.
As I said, neither of these is working for me.
What else should I consider in order to achieve my goal of having
document instances be able to reach back and talk to the preference
object? Thanks...
--
Aaron Braunstein
"Good enough" shouldn't be. From there the fall into mediocrity and
indifference is a short one.
_______________________________________________
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.