Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing same set of coding in different view controller
    primarykey
    data
    text
    <p>I have a same set of coding that have to be used in different view controller.what I have to do, to avoid duplication of coding in every view controller.I couldn't find the exact solution in google.Can any one help me please. </p> <pre><code>[super viewDidLoad]; // Do any additional setup after loading the view from its nib. //NSLog(@"%d",rowno); NSString *urlString=[NSString stringWithFormat:@"http://www.tranzlogix.com/tranzlogix_webservice/vehiclelist.php?format=json"]; NSURL *url=[NSURL URLWithString:urlString]; NSData *data=[NSData dataWithContentsOfURL:url]; NSError *error; //NSLog(@"%@",data); NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&amp;error]; //NSLog(@"%@",json); results = [json valueForKey:@"posts"]; //NSLog(@"%@", results); //NSLog(@"Count %d", results.count); NSArray *res = [results valueForKey:@"post"]; //NSLog(@"%@", res); Vehicle_No=[res valueForKey:@"vehicle_no"]; //NSLog(@"%@", Vehicle_No); Vehicle_No_Org =[Vehicle_No objectAtIndex:rowno]; NSString *CellText=[NSString stringWithFormat:@"%@",Vehicle_No_Org]; //NSLog(@"%@",CellText); //MAP VIEW WebService NSString *urlMapString=[NSString stringWithFormat:@"http://www.tranzlogix.com/tranzlogix_webservice/map.php?format=json&amp;truckno=%@",CellText]; //NSLog(@"%@",urlMapString); NSURL *urlMap=[NSURL URLWithString:urlMapString]; NSData *dataMap=[NSData dataWithContentsOfURL:urlMap]; NSError *errorMap; //NSLog(@"%@",dataMap); NSDictionary *jsonMap = [NSJSONSerialization JSONObjectWithData:dataMap options:kNilOptions error:&amp;errorMap]; //NSLog(@"%@",jsonMap); NSArray *resultsMap = [jsonMap valueForKey:@"posts"]; NSLog(@"%@", resultsMap); //NSLog(@"Count %d", resultsMap.count); NSArray *resMap = [resultsMap valueForKey:@"post"]; //NSLog(@"%@", resultsMap); NSArray *latitudeString=[resMap valueForKey:@"latitude"]; NSLog(@"%@", latitudeString); NSString *latOrgstring = [latitudeString objectAtIndex:0]; NSLog(@"%@", latOrgstring); double latitude=[latOrgstring doubleValue]; //NSLog(@"latdouble: %f", latitude); NSArray *longitudeString=[resMap valueForKey:@"longitude"]; NSLog(@"%@", longitudeString); NSString *longOrgstring = [longitudeString objectAtIndex:0]; NSLog(@"%@", longOrgstring); double longitude=[longOrgstring doubleValue]; NSLog(@"latdouble: %f", longitude); </code></pre> <p>This is what i need in more than two view controller one in map view and next in table view...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload