Re: Could not connect the action to target of class
Re: Could not connect the action to target of class
- Subject: Re: Could not connect the action to target of class
- From: Hamish Allan <email@hidden>
- Date: Sat, 12 Mar 2005 20:10:58 +0000
Thank you, Sherm, for such a comprehensive reply. I understand a great
deal more now.
I don't need multiple window controllers, but would you agree with me
that I need a view-controller?
I think we're referring to the same thing by different names. I call
it a "window controller" because that's the class it's derived from,
you're calling it a "view controller" because that's the role it plays
in your app design - but we're really talking about the same object.
Sorry for the confusion!
Not at all, I should have said "I don't need multiple window
controllers, but would you agree with me that I need at least one?"
which is what I really meant. I got my terminology from Apple's
"Document Architecture" document:
http://developer.apple.com/documentation/Cocoa/Conceptual/
AppArchitecture/Concepts/DocumentArchitecture.html
which talks about NSDocuments being model-controllers and
NSWindowControllers being view-controllers.
I think I had something close to the solution you described in my
project's initial incarnation, but I had copied it from a tutorial
without really understanding what was going on. Now that (I think) I
do, it strikes me I might rename "MyDocument.nib" to
"MyController.nib", because then it's obvious what the File's Owner
refers to.
You have two options for handling action messages. If you connect them
to the "File's Owner" in IB, they'll go the the view controller; it
could use [self document] to get its parent document when it needs to
forward messages it doesn't want to handle for itself. Or, since the
document object is part of the responder chain, you could send
messages to "First Responder" instead. The first option is good if you
want your view controller to do something in addition to sending a
message to the document, such as tell some view objects to update
themselves.
Now I don't think I understand the responder chain much yet but the
possibilities sound exciting. It slightly scares me that if I pick a
message name also understood by some other object I know nothing about
it might affect the behaviour of my application!
You have the right idea, as far as splitting up your controller layer
into separate model and view controllers. It's just that, in a
document-based app, you usually want to create the view controller(s)
in -makeWindowControllers. When you do it that way, and call
-addWindowController:, NSDocument will automatically make itself the
delegate of the view controller, keep track of the active view
controllers, and so forth.
Excellent. That puts several more pieces in the jigsaw for me.
So is it not possible to instantiate and connect view-controllers
from within IB at all?
It's possible, I'm sure. But it runs "against the grain" of the
document architecture, so it'd be more work.
No, I don't want to fight design decisions I am sure are more
well-reasoned than ones I might make :)
Thank you very much again,
Best wishes,
Hamish
_______________________________________________
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