在我的應用程序具有定位功能:問題在傳遞函數iphone之爭
- (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];
}
...我有其他功能,我想通過拉提和隆基:
-(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];
}
}
我怎樣才能做到這一點?我只需要在ParseXML_of_Googe_PlacesApi:
方法中的值lati
和longi
。其他一切工作正常
您傳遞參數'_googleUrl'爲'ParseXML_of_Google_PlacesAPI:'但是你沒有在該方法中使用它。 – TechZen