hopefully a pretty simple question. as you can see in my code below i set two NSArray in my code within the viewdidload. The problem is that i cannot access neither of these Arrays outside of the viewDidLoad. Is there a way around this that will allow me to populate my cell.textlabel.text outside of the viewDidLoad?
Code as Follows:
- (void)viewDidLoad {
[super viewDidLoad];
NSURLSession *session = [NSURLSession sharedSession];
//URLText is from previous VC see .h file.
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.test.com/%@/%@.json", _URLText, _URLText]] completionHandler:^(
NSData *data,
NSURLResponse *response,
NSError *error) {
NSDictionary *vDB = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSArray *amountOfV = [vechileDB valueForKeyPath:@"amount"]; //how to assign nsstring from dictionary.
NSArray *makeOfV = [vDB valueForKeyPath:@"make"];
NSLog(@"%@ %@", makeOfV, amountOfV);
}];
//Run the completed task.
[dataTask resume];
}