Info window scenario
Info window scenario
- Subject: Info window scenario
- From: "e.sammer" <email@hidden>
- Date: Tue, 06 Nov 2001 17:30:45 -0500
good day to all...
i'm currently working on a document based app that
has certain "inspectors" or info windows, if you
will that are global (in functionality, not code,
specifically) to the app. what i've done it
created a separate nib loading / controller class
for each inspector that maintains a shared
instance of the class (similar to NSNotification's
defaultCenter selector). nothing new here...
the problem i'm running into is that the info
window should update depending on which document
is selected and populate it's controls with the
document's preferences (i.e. an RTF / plain text
selection). this hasn't been a problem since all
of the document instances have access to the
shared instance of my info controller class simply
by something like [[InfoController sharedInfo]
populateInfoWithDocument:self].
the real problem is pushing the new values in the
info window back to the document when an "Apply"
button is clicked. the best i can come up with is
finding out which document is current by keeping a
reference to the "current document" by catching a
windowDidBecomeKey notification and testing with:
[[[[notification object] windowController]
document] isMemberOfClass:[MyDocument class]]
and if so, doing [[InfoController sharedInfo]
setCurrentDocument:theDoc]. then, the apply button
can work because i have a reference to the current
document.
this feels like a total hack. there has to be a
better way of doing this. i know this is common
thing to do (and i've done it when it's not a
document based app), but it seems like there's no
clear way to accomplish this. the only thing i can
think of is posting a notification that contains a
reference to the InfoController class to let all
documents know that the preferences changed, but
this is not clean and feels like bad design. i'm
open to any suggestions. if more details are
needed, i'm more than happy to give them. thanks
in advance to anyone who can help!!!
--
e.sammer
email@hidden