Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有数据从一个 RestAPI 传递过来,它有一个名为 location 的数组字段,其中包含一个 lat & lng。
我想知道将其存储在 CoreData 中的最佳方法是 CLLocation、原始 lat/lng 作为双精度值还是可转换的?除了如何存储它,我如何映射它?
不确定为什么将 lat/long 作为数组传递,这听起来不像是精心设计的 API。如果它是一个数组,那么最简单的做法是将其存储为可转换的,并在对象上提供一个自定义方法以返回一个CLCoordinate2D. 这样做的缺点是您将无法编写谓词来根据位置进行搜索。如果您想按位置搜索,您可能希望将原始纬度/经度值存储为双精度值,但听起来映射这可能很困难。
CLCoordinate2D