Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mistergreen2011

macrumors member
Original poster
Mar 23, 2011
36
0
Hi folks,

I have an app that need a fairly complicate key array/nsdictionary list that it uses to calculate other information. The data isn't large and it needs to be accessible from several classes.

I've been reading around and people have used several methods, a singleton class , EXTERN variables, and property list.

I think apple recommends using plist?

And I would write code to populate the plist with the array. Where do I put this code, in the application didFinishedLaunching? So the xml/plist gets written or rewritten every time the application is launched?

thanks.
 
My immediate gut-instinct would be to create a singleton class at the Application level with class methods for using and accessing its features.

Since it's a singleton class I would try to implement lazy loading. It would only load the data upon first call or after having dumped the data due to a memory warning.
 
I think we are talking about two different things here. If we are talking about persisting a small bit of data then a plist is likely the answer. When it comes to accessing the same data from several classes then singleton is the answer. So in your case you probably want to load data from a plist into a singleton.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.