Document-based app: design question
Document-based app: design question
- Subject: Document-based app: design question
- From: Luc Van Bogaert <email@hidden>
- Date: Fri, 21 Oct 2011 09:39:08 +0200
Hi,
I'm using the following piece of code in several places to get a pointer to the "active" windowController in my document-based application:
NSDocument *currentDocument = [[NSDocumentController sharedDocumentController] currentDocument];
if (!currentDocument)
return;
NSWindowController *windowController = [[currentDocument windowControllers] objectAtIndex:0];
if (![windowController isMemberOfClass:[DSSketchLibraryWindowController class]])
return;
Obviously, I'm looking for a way to refactor this duplicate code. Since this code is used in several different classes, I need to put it someplace where I can easily reference it. AppDelegate comes to mind. So, I'm wondering if putting this code in a public method in the application delegate would be the correct "cocoa way" of doing things?
Thanks for any advice.
--
Luc Van Bogaert.
_______________________________________________
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