I communicate with a json api in my cocoa (touch) app.
As a response I get something like this:
"wh": {
"1": ["11.30 - 15.00"],
"3": ["11.30 - 15.00"],
"2": ["12.00 - 14.00", "17.30 - 23.00"],
"5": ["11.30 - 15.00"],
"4": ["11.30 - 15.00"]
},
Keys 0 to 6 reflect the weekdays (Monday == 0, Tuesday = 1, ….)
To map this I have a NSArray:
weekdays = [[NSArray alloc] initWithObjects:@"Montag",
@"Dienstag",
@"Mittwoch",
@"Donnerstag",
@"Freitag",
@"Samstag",
@"Sonntag", nil];
I need this in two viewcontrollers – currently set in the viewWillAppear. 🙁
So my question(s):
- Where/When should I set this weekdays array?
- How to access it in the viewcontrollers?
- Any suggestions?
Use a singleton to store that kind of information, here is an example:
http://getsetgames.com/2009/08/30/the-objective-c-singleton/