I have the need for a 2-dimensional look-up table for my app. I wanted to do this as simply as possible, so I just made a series of arrays, and then will just call the appropriate array and position within that array whenever needed. However, this takes about 500 arrays... here is a code snippet:
NSArray *key_1 = [[NSArray alloc] initWithObjects:@"1",@"0.5038",@"0.8054",@"4.51",nil];
NSArray *key_2 = [[NSArray alloc] initWithObjects:@"1",@"0.4869",@"0.8009",@"4.7",nil];
NSArray *key_3 = [[NSArray alloc] initWithObjects:@"1",@"0.4708",@"0.7967",@"4.9",nil];
NSArray *key_4 = [[NSArray alloc] initWithObjects:@"1",@"0.4554",@"0.7926",@"5.09",nil];
NSArray *key_5 = [[NSArray alloc] initWithObjects:@"1",@"0.4407",@"0.7889",@"5.27",nil];
NSArray *key_6 = [[NSArray alloc] initWithObjects:@"1",@"0.426",@"0.7853",@"5.46",nil];
NSArray *key_7 = [[NSArray alloc] initWithObjects:@"1",@"0.4133",@"0.7819",@"5.65",nil];
However, I have two concerns. First, if these 500 array declarations cause a momentary hang in the app, where should I put this code so that it executes while still on the app's splash screen when first starting up? Would that be in viewWillAppear
?
Second (and this is probably more of a newb question), if I place these array declarations in viewWillAppear
or some other method in my FirstViewController.m, how can I make them accessible to methods in my SecondViewController.m?
Thanks!