How should my controller objects reference eachother?
How should my controller objects reference eachother?
- Subject: How should my controller objects reference eachother?
- From: "Carter R. Harrison" <email@hidden>
- Date: Mon, 23 Jul 2007 20:23:02 -0400
Good evening everybody,
I'm in the middle of my first big Cocoa project. I've been working
hard to keep all of my various controller objects as concise as
possible. As part of this effort, I've begun to realize that my
controllers need to reference each other so that they can easily send
messages to one another. What's the best way to do this?
My first inclination was to have my application's delegate maintain
references to each controller object, and then each of my controller
objects could get a reference to one another by getting it from the
app delegate via accessor methods that I would create. This doesn't
seem to be working out - I keep getting warnings from the compiler
that these accessor methods don't exist.
Here's an example. Let's say I have three controllers:
FileController (extends NSArrayController), HTTPSubsystem (extends
NSObject), GUIController (extends NSObject). All three controllers
need to reference each-other. In the example below if I call "http =
[[NSApp delegate] httpSubsystem];" from within FileController.m, I
receive the following compiler message: "no '-httpSubsystem' method
found. I hope all this makes sense, and thanks very much in advance.
AppDelegate.h
@interface AppDelegate : NSObject
{
IBOutlet FileController *fileController;
IBOutlet GUIController *guiController;
HTTPSubsystem *http; //This controller is alloc'd when the
AppDelegate awakes from nib.
}
// Accessor methods.
- (FileController *)fileController; //returns fileController
- (GUIController *)guiController; //returns guiController
- (HTTPSubsystem *)httpSubsystem; //returns http
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden