- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在从 CLPlacemark 中提取地址字典,但我没有收到任何错误或任何信息,但 key 似乎与 Apple 文档显示的内容不一致。
来自 CLPlacemark 类:
// address dictionary properties
var name: String! { get } // eg. Apple Inc.
var thoroughfare: String! { get } // street address, eg. 1 Infinite Loop
var subThoroughfare: String! { get } // eg. 1
...
但是当我得到 placemark.name 时,它会返回街道地址,例如。 1 无限循环。当我得到 placemark.thoroughfare 时,它只返回街道名称,而不是它看起来应该返回的数字。 placemark.subThoroughfare 确实包含建筑物编号,所以目前我只是将 subThoroughfare 和 thoroughfare 连接起来,但我担心如果 placemark.thoroughfare 返回编号和街道名称,我偶尔会偶尔获得两个建筑物编号。
这是错误还是什么,我可以指望像这样连接字符串吗?
最佳答案
在我看来,这些评论中有一个错误。读书the documentation建议 thoroughfare
只会返回街道名称,如您所说:
The street address contains the street name. For example, if the placemark location is Apple’s headquarters, the value for this property would be the string “Infinite Loop”.
阅读相同的文档,在 subThoroughfare
下, 看起来你也在那里:
Subthroughfares provide information such as the street number for the location. For example, if the placemark location is Apple’s headquarters (1 Infinite Loop), the value for this property would be the string “1”.
至于name
,那只是系统为地标设置的名称。对于某些地方,它只是地址。对于系统有更多信息的其他人,我相信它会更加用户友好(“Walmart”、“Stack Exchange Offices”等)
不过,您的意图似乎只是获取地标的地址。为此,我会使用 addressDictionary
属性并让系统(即 ABCreateStringWithAddressDictionary
)处理讨厌的部分:
address = ABCreateStringWithAddressDictionary(myPlacemark.addressDictionary, false);
请注意,我相信这将为您提供系统的最佳解释,并且可能会包括城市、州、 zip 等。
关于ios - CLPlacemark 'name' 返回街道地址,而 'thoroughfare' 仅返回街道名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27003429/
这是我在 StackOverflow 上找到的部分代码。 它在 Swift 1.2 中工作为什么此代码在 swift 2 中不再有效: geoCoder.reverseGeocodeLocation(
我有一个标签显示属于确切地理位置的街道名称。我正在从 placemarkStreet 变量中检索街道名称,它工作正常,但有时当我登录 placemark.thoroughfare 时,它是一个 (nu
我想显示用户位置的完整街道名称,使用以下代码我只能显示城市名称: -(void) reverseGeocode:(CLLocation *)location{ CLGeocoder *geoco
我想知道是否可以从 CLPlacemark 获取州的缩写? 在 Apple 的 CLPlacemark Reference 中它指出: 行政区域与地标关联的州或省。 (只读)@property(non
我正在尝试了解 CLPlacemark 以及何时/如何为添加到 map 的图钉标注创建信息。在我几年前在更多 iOS 3 开发中读到的内容之前,他们对地址进行了反向地理编码并构建了地址(街道、邮政编码
我找遍了所有地方,但没有找到这个问题的答案。 我正在构建一个使用用户位置(经纬度)的 iOS 应用程序创建一个 CLPlacemark,并将街道+国家/地区发送到服务器并根据此位置返回响应。 现在服务
几天前我几乎没有尝试在我的 iPhone 上的消息正文中嵌入我的当前位置,但我失败了。 我想尽了所有办法,但我只得到了错误 我得到的最后一个错误是 "fatal error: unexpectedly
我有一个尝试更新我的授权状态的方法。 使用 PromiseKit 6、Swift 4.2,我似乎无法让我的 Promise 成为一个 CLPlacemark。 这会导致一连串的错误 Value of
是否可以检查 CLPlacemark's 是否存在?名称是街道地址? 如果是购物中心、主题公园、学校或其他有趣的东西,我想显示名称,但如果是街道地址,则不显示。 我正在考虑使用这样的正则表达式来检查名
如何在 Swift 中将 MKMapItem 转换为 CLPlacemark? 我的代码给我一个编译器错误 'MKMapItem' is not convertible to 'CLPlacemark
谁能建议清洁工从 CLPlacemark 创建地址字符串。 目前我正在使用这个扩展 extension CLPlacemark { func makeAddressString() -> St
我有一个移动 CLPlacemark 对象并使用它们的应用程序,我想对与它们交互的几个组件进行单元测试。为此,我希望能够使用生成具有已知值的模拟 CLPlacemark 的方法来阻止 MapKit 对
我正在使用 MKLocalSearch 搜索某些地方,例如城市或城市中的街道,以在 MKMapView 上显示它们 我这样显示地标 let loc = placemark.location! //CL
我正在尝试检测地标值是否包含某些值。为此,我在 NSString 上使用了 rangeOfString 方法。但是,rangeOfString 可以像我期望的那样处理字符串,但不能像我期望的那样处理地
Reading the documentation ,苹果指向ABPerson在 CLPlacemark 的 addressDictionary 上使用的键。 但自 iOS 9 以来,ABPerson
当注销或发送(使用 RestKit 的 Web 服务)时,特别是 CLPlacemark 的 subThoroughfare 属性出现奇怪的字符,我希望连字符出现。 记录: NSLog(@"%@",
我必须从 CLPlaceMark 中取出 map_region 和类型,但在 CLPlaceMark 类中找不到可以提供 map_region 值的属性。 { placeData =
我正在尝试提取在 CLPlacemark 对象中返回的 dependentLocality 信息。数据(匿名)看起来像 { "cache_control" = CACHEABL
我使用 CLGeocoder 将 CLLocation 从经度/纬度解码为地名。它工作正常。但是还有一件事困扰着我。当我将设备语言设置为英语时,以下代码的结果: - (void)locationMan
我正在使用 CLGeocoder 进行反向地理定位并获取 CLPlacemark 数组。当我在美国境外使用 GPS(即 -27,127)然后访问 placemark.postalCode 时,应用程序
我是一名优秀的程序员,十分优秀!