转换MKPlaceMark addressDictionary字符串编码 [英] convert MKPlaceMark addressDictionary string encoded

查看:173
本文介绍了转换MKPlaceMark addressDictionary字符串编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个使用MKReverseGeocoder将经纬度转换为地址的示例.但是,当我收到数据并尝试获取结果时,我收到的字符串如下:

I working on a example to using MKReverseGeocoder to convert lat,long to address. But when i received data and try to get the result i received string from as below:

NSString *street = [geocoder.addressDictionary objectForKey:@"Street"];

我收到了这样的地址:"Ng \ U00f5 381 Nguy \ U1ec5n Khang" .

I received a address like this: "Ng\U00f5 381 Nguy\U1ec5n Khang".

如何将其转换为unicode格式的字符串?

How can i convert it to unicode formatted string?

谢谢.

推荐答案

如果要从MKRevereseGeocoder委托回调中获取MKPlaceMark对象,则可以使用以下操作将地标转换为可读地址:

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));

您需要将AddressBookUI框架添加到您的项目中,然后

You need to add the AddressBookUI framework to your project and

#import <AddressBookUI/AddressBookUI.h>

也是.

我不确定响应是否为unicode,但是看起来它在表示地标中的所有数据方面做得很合理.

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.

未经测试,但

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

所需的框架是联系人",因此将其包含在以下内容中:

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

@import Contacts;

应该是iOS11.0 +中新的工作方式

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

这篇关于转换MKPlaceMark addressDictionary字符串编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆