• 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
Re: Document-based app: design question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Document-based app: design question


  • Subject: Re: Document-based app: design question
  • From: Citizen <email@hidden>
  • Date: Fri, 21 Oct 2011 09:13:59 +0100

One way of dealing with this is to make the method part of an informal protocol and check before calling it. Details are here:
http://cocoadevcentral.com/articles/000075.php

------
David Kennedy (http://www.zenopolis.com)


On 21 Oct 2011, at 08:39, Luc Van Bogaert wrote:

> 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

_______________________________________________

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

References: 
 >Document-based app: design question (From: Luc Van Bogaert <email@hidden>)

  • Prev by Date: Document-based app: design question
  • Next by Date: Exception when entering too big value in text field (with number formatter)
  • Previous by thread: Document-based app: design question
  • Next by thread: Exception when entering too big value in text field (with number formatter)
  • Index(es):
    • Date
    • Thread