gpt4 book ai didi

ios - CLPlacemark 'name' 返回街道地址,而 'thoroughfare' 仅返回街道名称

转载 作者:搜寻专家 更新时间:2023-11-01 06:24:06 25 4
gpt4 key购买 nike

我正在从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com