ios - Using variables defined in one method inside another in Objective-C -


i have function so: (and ps - new 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 have of previous strings defined , need call variables in 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 best way this?

define these variables in more global scope, in interface file.

by defining variables in interface file (.h file), have access in method of implementation file. (.m file)


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -