boscarol
boscarol

Reputation: 1941

Reading an object from another class

I am using XCode 4.0.2 for a iOS4 project.

When my app starts, the application didFinishLaunchingWithOptions method in the application delegate loads a NSDictionary form a plist:

NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"RGBSpaces" ofType:@"plist"];
RGBSpacesDictionary = [NSDictionary dictionaryWithContentsOfFile:plistPath];

The NSDictionary is readonly. How can I read one or more elements of NSDictionary from an arbitrary class?

Thank you

Upvotes: 0

Views: 81

Answers (2)

mrugen munshi
mrugen munshi

Reputation: 3607

Rather then doing with Appdelegate the simpler option would be create a class for that of type NSObject and you update and get value just by importing that class wherever required.Another option would be NSUserDefaults.Depends on the requirements which to use.

Upvotes: 0

fatih
fatih

Reputation: 1181

UIApplication *appDelegate = [[UIApplication sharedApplication] delegate];

And then you can use appDelegate to access its properties including dictionaries.

Upvotes: 3

Related Questions