Multiple, different, single documents (or: which FM to R?)
Multiple, different, single documents (or: which FM to R?)
- Subject: Multiple, different, single documents (or: which FM to R?)
- From: "Paul M. Lambert" <email@hidden>
- Date: Mon, 27 Dec 2004 04:10:18 -0800
I'm pretty new to ObjectiveC and Cocoa, and I've chosen what is probably
a bad idea for my first project.
I've gone through Cocoa Programming for Mac OS X 2nd Edition and Core
Mac OS X and UNIX Programming, and I keep thinking I understand
everything I need to know. But the walls I'm hitting suggest I don't.
A push in the right direction would be really appreciated; I'm sure this
is obvious to anyone who's done this a few times.
I would like to know a good way to go about building an application
whose UI consists of a three windows.
Each window should be "persistent," in that closing it only hides it,
but never deallocates or removes it.
The first window I can handle just fine. It's a utility window with no
special behaviors that I haven't been able to do with bindings and a
simple bit of code. No data is shared between this window and the
others...
The second window maintains a list of data objects. These objects are
described by a class, and the UI is to be a list and detail view. I can
handle the editing of the list, but I would like to make it persistent.
This list should be transparently saved when the application quits, and
all changes should be immediately saved to disk. Is NSPreferences the
right way to go? Or should I create a custom file? Anyone know of
sample code that could point to this? The list of objects could become
pretty large, but I'll worry about performance another day.
The third window is the tricky one. It's a single window which
should also be "persistent" _and_ allow saving to a file, opening from a
saved file, etc. If the application is quit, it shouldn't prompt to
save this window, instead just saving it to the internal preferences (?)
and restoring that at next launch. Only when the application is first
installed is it likely that the data model will be empty; after that,
emptiness is intentional.
The third window also uses the objects managed in the
second window. It never modifies those objects, but copies them to new
objects and modifies those (which would then be saved).
In my original attempt, I created a new project as a Cocoa Application
and built my three windows in the MainMenu.nib. I created a controller
class for the first window, and it works fine. I created a controller
class for the second window, and got it working as well. But when I
went to make the third window work, I realized my second window had the
managed NSMutableArray in the NSArrayController directly. So I tried to
move it into a separate controller and bind it, but now I've confused
myself and my project horribly.
I won't understand these things well, until I do them myself. But a
nudge in the right direction would be of great help. I'm thinking now I
should put each window in its own nib file, and load them as needed.
Then I'll need an application controller class to contain the data for
the second and third windows. Then I just need to figure out how to get
the second and third windows to have bindings to that controller; can I
do it via File's Owner? Or must I create the bindings manually in
awakeFromNib?
Thanks for any suggestions; I know I'm on the wrong track somewhere, and
I'd love any pointers that anyone can give.
Paul M. Lambert
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden