I’ll try and make this quick:
I’ve an external class that parses the JSON from a webservice (the JSON itself is fine, I’ve done it locally now I’m making it web accessible) and then these values will be used for comparisons. However I can’t access the variables in every case. My intent is to parse them once and be able to access them whenever
The parser is being loaded from the the app delegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application{
ld =[[ loader alloc] init];
[ld parse];
}
The contents of the connectingDidFinishLoading:
jsonString = [[NSString alloc] initWithData:re encoding:NSUTF8StringEncoding];
//NSLog(@"LOADER %@", jsonString);
SBJsonParser *parser = [SBJsonParser new];
se = (NSMutableDictionary *)[parser objectWithString:jsonString];
searchR = [se objectForKey:@"menu"];
s = [[[NSMutableArray alloc] initWithArray:[searchR objectForKey:@"tip1"] ] retain];
NSLog(@"TROLL2 %@", [s objectAtIndex:0 ]);
This comes back correct
However in the first page loaded at the end of the viewDidLoad:
lt = [[loader alloc] init];
NSLog(@"CALLED %@", [lt.s objectAtIndex:0] );
This comes back null, and before anyone asks, s is a property of the loader class.
Just wondering if I need a callback to ensure the class is properly loaded or am I just having a stupid day and calling it wrong from the first page
Here's the `timestaps`:
2011-07-28 13:59:07.183 [44330:40b] TROLL2 top aaaft
2011-07-28 13:59:07.371 [44330:40b] CALLED (null)
Thanks for your time reading this
Wouldn’t you have to access the app delegate rather than initialize a new one?
MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];NSLog(@"CALLED %@", [delegate.lt.s objectAtIndex:0] );