convert MKPlaceMark addressDictionary string encoded

无人久伴 提交于 2019-12-05 17:21:04

If you are getting the MKPlaceMark object back from the MKRevereseGeocoder delegate callback you can use the following to turn the placemark into a readable address:

NSLog(@"Address of placemark: %@", ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO));

You need to add the AddressBookUI framework to your project and

#import <AddressBookUI/AddressBookUI.h>

as well.

I'm not sure that the response is unicode, but it looks like it does a reasonable job of representing all the data in the placemark.

Untested, but

NSLog(@"Address of placemark: %@", [CNPostalAddressFormatter stringFromPostalAddress:placeMark.postalAddress style:CNPostalAddressFormatterStyleMailingAddress]);

And the framework needed is 'Contacts' so get that included with:

@import Contacts;

should be the new way of doing things in iOS11.0+

tarek1985

If you are getting the MKPlaceMark object back from the MKRevereseGeocoder delegate callback you can use the following to turn the placemark into a readable address:

NSLog(@"The geocoder has returned: %@", [placemark addressDictionary]);
//all elements returned

//you can get some object like coutry ,code ;code country ...

NSLog(@"country ::::%@",[placemark country]);

NSLog(@"countrycode ::::%@",[placemark countryCode]);

NSLog(@"postalcode ::::%@",[placemark postalcode]);

NSLog(@"street::::%@",[placemark thoroughfare]);

 NSLog(@"streetinfo::::%@",[placemark administrativeArea]);

NSLog(@"streeteersub ::::%@",[placemark subAdministrativeArea]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!