• 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: objects and "global / shared data"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objects and "global / shared data"


  • Subject: Re: objects and "global / shared data"
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 03 May 2011 16:19:34 -0600

On May 3, 2011, at 4:08 PM, Martin Batholdy wrote:

> Now how can I make sure that a global data-source is available independent from instances and their state?
> How can I share data between objects?

I would recommend making a singleton "manager" object that holds instances of this data handler object, and can be used to query these objects. We do this with data stores in several of our projects, and it works quite well. You may only have one data store object at this time, but if you ever need to add more than one, it's cheaper to adopt this design now than it is to uproot things later.

> I read something about singletons and that  by declaring the DataHandler object a singleton I can make sure that over the whole program only one DataHandler-instance is initiated,
> and the actual Data-Array is the same in each instance.
>
> But I also read that singletons are bad practice.

That is not true. Where did you read that?

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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: 
 >objects and "global / shared data" (From: Martin Batholdy <email@hidden>)

  • Prev by Date: objects and "global / shared data"
  • Next by Date: Re: objects and "global / shared data"
  • Previous by thread: objects and "global / shared data"
  • Next by thread: Re: objects and "global / shared data"
  • Index(es):
    • Date
    • Thread