Re: Controller layer & document architecture
Re: Controller layer & document architecture
- Subject: Re: Controller layer & document architecture
- From: Ken Tabb <email@hidden>
- Date: Wed, 23 Jun 2004 18:44:02 +0100
Hi Scott,
thanks for the reply. Sorry about the newbie questions, but I'm finding
that until I have something to play with, I won't know the right
questions to ask (chicken and egg).
So if I bind to a method in my app delegate which returns
[[NSDocumentController sharedDocumentController] currentDocument],
would my controller automagically update the info window's contents
each time a different document window becomes main? Having read the
currency converter bindings tutorial I'm a bit concerned about the
bi-directional synching of info... is there a risk that the controller
might update the wrong model with the view info, or vice versa, during
the time when a different document window is becoming frontmost?
Also if there is no currentDocument (eg. all document windows are
closed) will that wreck the binding? I'm guessing my app delegate
method would return nil, but how would the controller know to display
"no document open" or "no object selected" or some such (like IB's
inspector panel does). This question probably sounds stupid, I
appreciate that, but I'm hoping there'd be a method in the controller
somewhere where I simply go:
{
...
if([[NSApp delegate] currentDocument] != nil)
{
//do magic synching stuff with selected object(s), eg. using [super
whateverThisMethodIsCalled]
}
else //no document windows open
{
//display "nothing to see here, move along" view in info window
}
...
}
Wishful thinking?!
Thanks again,
Ken
On 23 Jun 2004, at 5:08 pm, Scott Anguish wrote:
hi ken
in a nutshell, you need to create a method on your application
delegate (or someplace similar) that will give you the front most
document, and then bind through that for anything in your inspector.
that make sense??
On Jun 23, 2004, at 11:25 AM, Ken Tabb wrote:
Hi again folks,
I have a noddy question about the (fairly) new controller layer.
I have a document-based app and a standard info utility window which
needs to display info about a single, or group of, selected objects
in a document, but when the main window changes (i.e. user selects
another document window), I want the same info window to display info
about the selected object(s) in the new document, i.e. the info
window is 1 per app, not 1 per document.
If I wanted to hook a controller to the info window and a model
object in the current document, do I have 1 controller per document
or 1 per app?
If I have 1 controller per document will I run into issues where
several controllers are hooked up to the info window and are all
updating their model object based on the info being typed into the
info window?
Conversely if I have 1 controller per app, what's the best way to
swap the document to which it is synching info? Using the document
controller to get the frontmost document, or using notifications from
the document windows (eg. that the window just became / resigned
main)?
I'm just beginning the move to the controller layer so apologies if
any of these questions sound stupid,
Ken
- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Technical bloke (C, C++, Obj-C, Java) - Health & Human
Sciences
Machine Vision & Neural Network researcher bloke - Computer Science
Dept
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider
_______________________________________________
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.
- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Technical bloke (C, C++, Obj-C, Java) - Health & Human
Sciences
Machine Vision & Neural Network researcher bloke - Computer Science Dept
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider
_______________________________________________
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.