• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Document-based app: design question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Document-based app: design question
      • From: Citizen <email@hidden>
  • Prev by Date: Re: WebView doesn't scroll
  • Next by Date: Re: Document-based app: design question
  • Previous by thread: Re: Core Data: Determine if managed object is deleted
  • Next by thread: Re: Document-based app: design question
  • Index(es):
    • Date
    • Thread