2010-09-02 82 views
3

我正在开发基于地理编码器的应用程序。在我的应用程序中,为了获取用户当前的地址,我在地理编码委托方法中使用了地标地址字典方法,然后,我可以获取邮政编码以外的所有详细信息(街道,城市,州,县,国家代码和全部)。为什么邮政编码不会来?现在我正在使用iOS 4.请帮助我。为什么邮政编码不在地址字典上?

我的代码,

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark 
{ 
     placemark = [[MKPlacemark alloc] initWithCoordinate:locationManager.location.coordinate addressDictionary:[placemark addressDictionary]]; 

     NSLog(@"Address Dictionary %@", [placemark addressDictionary]); 

     NSDictionary * addressDict= [placemark addressDictionary]; 

     country = [addressDict objectForKey:@"Country"]; 

     postal = [addressDict objectForKey:@"PostalCode"]; 

     state = [addressDict objectForKey:@"State"]; 

     city = [addressDict objectForKey:@"City"]; 

} 

这是我目前的地址,这是从标地址字典。

Address Dictionary { 
City = Madurai; 
Country = India; 
CountryCode = IN; 
FormattedAddressLines =  (
    "Lady Doak College Rd, Chinna Chokkikulam, Chockikulam", 
    "Madurai, Tamil Nadu", 
    India 
); 
State = "Tamil Nadu"; 
Street = "Lady Doak College Rd"; 
SubAdministrativeArea = Madurai; 
SubLocality = "Chinna Chokkikulam"; 
Thoroughfare = "Lady Doak College Rd"; 
} 

在上面的代码中,没有poastalCode。但我需要邮政编码。获取邮政编码,我想要做什么?请给出一个解决方案。

回答

0

我已经通过去除低于线,解决了我的问题没有必要初始地标。

placemark = [[MKPlacemark alloc] initWithCoordinate:locationManager.location.coordinate addressDictionary:[placemark addressDictionary]];