• 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: Accessing shared (global) data object from nib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing shared (global) data object from nib


  • Subject: Re: Accessing shared (global) data object from nib
  • From: Clark Cox <email@hidden>
  • Date: Tue, 16 Nov 2004 21:46:43 -0500

On Wed, 17 Nov 2004 13:15:30 +1100, Andrew White
<email@hidden> wrote:
> Joakim Danielson wrote:
> > Why don't you make CommonData a singleton, as such it can be called
> > from anywhere in your application, i.e [[CommonData sharedInstance]
> > someMethod].
>
> How do I instantiate a singleton?  This is what I was getting at with the
> 'Add a method to the CommonData class to allow a single instance to be
> globally obtained' suggestion, but I don't know how to instantiate or store
> the singleton instance.

+(id)sharedInstance
{
  static id instance;
  if(instance == nil)
  {
    instance = [[CommonData alloc] init];
  }
  return instance;
}


--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Accessing shared (global) data object from nib (From: Andrew White <email@hidden>)
 >Re: Accessing shared (global) data object from nib (From: Joakim Danielson <email@hidden>)
 >Re: Accessing shared (global) data object from nib (From: Andrew White <email@hidden>)

  • Prev by Date: Re: Accessing shared (global) data object from nib
  • Next by Date: Re: Custom NSToolbarItem
  • Previous by thread: Re: Accessing shared (global) data object from nib
  • Next by thread: the image not the icon
  • Index(es):
    • Date
    • Thread