• 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: Passing References During Initialization / Nib Loading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing References During Initialization / Nib Loading


  • Subject: Re: Passing References During Initialization / Nib Loading
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 11 Jun 2009 19:10:07 -0700

On Jun 11, 2009, at 18:05, Brad Gibbs wrote:

Why not just use a singleton [[MainWindowController sharedWindowController] switchToView:[menuItems objectAtIndex: [menuItemsArrayController selectionIndex]] ?

There's nothing wrong with that approach, though it's not perhaps what might be understood as a "singleton". You happen to have only a single main window controller, and propose having a class method to get it, that's all. "Singleton" usually suggests code within the singleton's class to actively prevent other instances being created by unruly "client" code. That's not necessary here.


The only drawback with making your main window controller global, and it's perhaps a fairly theoretical concern, is that one of the benefits of encapsulating parts of your interface (such as multiple view nib files) is the elimination of global relationships that hamstring your code. Localizing the relationships makes the pieces easier to put together safely. In a way, this entire thread has been about the difficulty of accommodating a global reference across your entire application design.


_______________________________________________

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: Passing References During Initialization / Nib Loading
      • From: Michael Ash <email@hidden>
References: 
 >Passing References During Initialization / Nib Loading (From: Brad Gibbs <email@hidden>)
 >Re: Passing References During Initialization / Nib Loading (From: Quincey Morris <email@hidden>)
 >Re: Passing References During Initialization / Nib Loading (From: Brad Gibbs <email@hidden>)
 >Re: Passing References During Initialization / Nib Loading (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Questions on using using modal sheets with Core Data
  • Next by Date: NSFontPanelValidation broken?
  • Previous by thread: Re: Passing References During Initialization / Nib Loading
  • Next by thread: Re: Passing References During Initialization / Nib Loading
  • Index(es):
    • Date
    • Thread