I’m only starting with Objective-C and it’s still hard for me to do some pretty basic things. Here’s what I want to achieve – I need to create a class that would hold all static data of my application which I guess could be represented with a number of NSString ** arrays, such as this one:
NSString *animalNames[NUM_ANIMALS] = {@"fox", @"wolf", @"elephant", @"giraffe"};
I want to be able to access these arrays in a static way from anywhere in my application. Something like this:
StaticData.animalNames[1]
How would I accomplish this in terms of @property, @interface, @synthesize and all this stuff?
Here’s an example of what you are talking about. It’s a basic singleton class with a static array of your animals.
This application logs the following to the console:
EDIT:
If you favor the dot syntax/property notation, you could just implement the following in the class interface:
which would let you write:
etc.