Re: Responding from a delegate?
Re: Responding from a delegate?
- Subject: Re: Responding from a delegate?
- From: Kay Roepke <email@hidden>
- Date: Thu, 15 Apr 2004 21:28:32 +0200
One for mommie and one for the list...;-)
On 15. Apr 2004, at 21:09 Uhr, Sam Thorne wrote:
Thank you both for the help, here's where I'm getting confused; as I
understand it from Ondra's post, I need to set an instance var in the
GameToolbar delegate that points back to the GameWindowController, so
that when the IBAction in GameToolbar is triggered the window
controller can then tell it's window to open a drawer.
I've got this working fine without using the delegate class, but I'm
curious as to how I'd do it with delegation.
I'm guessing something along the lines of
toolbarDelegate = [[GameToolbar alloc] init];
[toolbarDelegate delegator:self];
and then setting up delegator as an accessor in the interface of
GameToolbar, would this be right?
That would be one way of doing it.
Personally I wouldn't call it delegator but rather windowController or
just controller (since the 'delegator' is the
toolbar, strictly speaking), but yes.
A different approach (albeit maybe a bit to complicated for this) would
be to ask get your currentDocument from the
sharedDocumentController for its windowControllers (usually there's
just one, but there might be more).
Then you would know which windowController to ask to toggle the drawer,
or whatever.
As I said, maybe a bit too far out, but way more flexible (which is
probably not what you want right now ;-))
If you just want to cut down on source lines in GameWindowController.m
you could also move those methods in a category
of GameWindowController (often the category file is named
GameWindowController+GameToolbarDelegate.m, i.e.
classname+categoryname).
That's what I do when source code files are getting out of hand and I
can't find anything anymore.
Kay
_______________________________________________
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.