• 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: IB connections - newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IB connections - newbie question


  • Subject: Re: IB connections - newbie question
  • From: Aidan Bahta <email@hidden>
  • Date: Thu, 6 Aug 2009 00:59:04 -0700

On Aug 5, 2009, at 10:34 PM, Greg Guerin wrote:

Oftenwrong Soong wrote:

I am making a NSDocument based app. In the NIB for the document window, I need to create a connection to a "global" data object (think singleton). This "global" data is used when creating the document, but isn't part of the document.

Normally I'd make a connection by dragging a NSObject into the NIB but that would instantiate a separate object for each open document. I want all open document(s) to share the same object.

How can I create such a connection between the NIB and my code?


Create a class, every instance of which refers to the singleton. These instances all act like funnels leading to the same place. No matter which instance you refer to in any nib, nor how many instances are instantiated, it ultimately all goes to the singleton.

-- GG



To follow the Singleton pattern in Cocoa, this documentation is a good starting point:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#/ /apple_ref/doc/uid/TP40002974-CH4-SW32


After you have adapted your class to follow the singleton pattern, you can instantiate it in your nib.

Aidan

_______________________________________________

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: 
 >Re: IB connections - newbie question (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: NSOperationQueue question
  • Next by Date: Re: Design Question
  • Previous by thread: Re: IB connections - newbie question
  • Next by thread: NSOutlineView Not Updating After Adding Items
  • Index(es):
    • Date
    • Thread