I have a function like so: (and ps - I am new to ios development)
- (void)loadJSON
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSURL *url = [NSURL URLWithString:@"http://jamessuske.com/isthedomeopen/isthedomeopenGetData.php"];
NSData *data = [NSData dataWithContentsOfURL:url options:0 error:nil];
NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSArray *firstItemArray = array[0];
NSString *yesNoString = firstItemArray[0];
NSString *dateString = firstItemArray[1];
NSString *timeString = firstItemArray[2];
NSString *homeString = firstItemArray[3];
NSString *awayString = firstItemArray[4];
NSString *lastUpdatedString = firstItemArray[5];
NSString *previousIsOpen = firstItemArray[6];
NSString *previousDate = firstItemArray[7];
NSString *previousHome = firstItemArray[8];
NSString *prviousHomeScore = firstItemArray[9];
NSString *previousAway = firstItemArray[10];
NSString *previousAwayScore = firstItemArray[11];
dispatch_async(dispatch_get_main_queue(), ^{
self.YesOrNo.text = yesNoString;
self.date.text = [@"For " stringByAppendingString:dateString];
self.time.text = timeString;
self.home.text = homeString;
self.away.text = awayString;
self.lastUpdated.text = lastUpdatedString;
self.lastUpdatedText.text = @"Last Updated";
self.vs.text = @"vs";
});
});
}
and I have all of those previous strings defined and I need to call those variables in my button action alert:
- (IBAction)PreviousResults:(id)sender {
UIAlertView *previousalert = [[UIAlertView alloc] initWithTitle: @"Previous Results" message: @previousIsOpen previousDate previousHome previousHomeScore previousAway previousAwayScore delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [previousalert show]; [previousalert release];
}
What would be the best way to do this?