2012-07-04 23 views

回答

0

首先你必须阅读所有关于XMLParsing,JSON解析的内容。 当您将了解所有关于解析的内容时,请转到下一步,这是API。找到一个网址为 的网络,它提供了ATM的详细信息...我建议你在ATM之前请使用谷歌的天气API ...这对初学者很容易。

+0

由于一吨! :=) – user1456663

+0

如果您有满意的话请投票:-) – TheTiger

4

所有你需要经过CLLocationManager类,帮助您获得您的当前位置

CLLocationManager *locationManager =  [[CLLocationManager alloc]init]; 
locationManager.delegate   =  self; 
[locationManager startUpdatingLocation]; 

以下代表将帮助您获得更新的位置

-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ 

} 

现在你可以使用第一谷歌地方api搜索任何东西在您当前的坐标附近

NSString *url = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/xml?location=%f,%f&radius=%.0f&types=%@&sensor=true&key=AIzaSyDIWlL",currentlatitude,currentlongitude,distanceinmeters,itemYouWantToSearch]; 

// here you have to use your own key and change the ivars according to your need. 

现在,你必须使用的NSXMLParser分析数据

NSXMLParser *itemParser = [[NSXMLParser alloc]initWithContentsOfURL:[NSURL URLWithString:url]]; 
[itemParser setDelegate:self]; 
[itemParser parse]; 

以下解析器代表将帮助你获得的数据

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 

{ 
//opening tag 
} 

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{ 
    //data of opening tag 
} 

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ 

//closing tag 
} 
+0

+1综合性很好的答案! – Anne

相关问题