In my application I have location function:
- (void)locationUpdate:(CLLocation *)location {
lati = [[NSString alloc]initWithFormat:@"%f", location.coordinate.latitude] ;
longi = [[NSString alloc ]initWithFormat:@"%f", location.coordinate.longitude ];
[self ParseXML_of_Google_PlacesAPI:googleUrl];
}
…and I have another function to which I want to pass lati and longi:
-(void)ParseXML_of_Google_PlacesAPI:(NSString *)_googleUrl {
//use lati and longi in this line
googleUrl=[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/xml?location=%f,%f&radius=500&name=asda&sensor=false&key=mykey",lati,longi];
NSURL *googlePlacesURL = [NSURL URLWithString:googleUrl ];
NSData *xmlData = [NSData dataWithContentsOfURL:googlePlacesURL];
xmlDocument = [[GDataXMLDocument alloc]initWithData:xmlData options:0 error:nil];
NSArray *arr = [xmlDocument.rootElement elementsForName:@"result"];
placesOutputArray=[[NSMutableArray alloc]init];
for(GDataXMLElement *e in arr ){
[placesOutputArray addObject:e];
}
}
How can I do that? I just need the values of lati and longi in the ParseXML_of_Googe_PlacesApi: method. Everything else is working fine
You need to modify the ParseXML_of_Google_PlacesAPI:(NSString *)_googleUrl method to take other arguments:
i.e )ParseXML_of_Google_PlacesAPI:(NSString *)_googleUrl long:(float) longitude lat:(float) latitude
You can use float if they floats or replace the float with NSString if they are nsstrings like in your method.
You can then use the nsstringformat to reformat your URL.