将 latitude/longitude 双倍转换为 MKMapItems 以获取方向

Converting latitude/longitude doubles into MKMapItems for obtaining directions

我正在做一个 Core Data 项目,早期我发现 MKMapItems 不符合 NSCoder,所以我将 MKMapItem 的坐标作为双精度存储在核心中数据并稍后检索它们以生成到目的地的路线。

我在下面的 post 中找到了有助于解释如何生成方向的答案,但我不知道如何转弯我的 latitude & longitude double回到 MKMapItem。这是可以做到的吗?

is there a way to get directions in mkmapview using a built in apple API?

@holex 为我指出了正确的解决方案方向。可以使用以下代码将 latitude/longitude 坐标从 Core Data 转换为 MKMapItem:

MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake([self.destinationLatitude doubleValue], [self.destinationLongitude doubleValue]) addressDictionary:nil];
MKMapItem *destination = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"Name of your location"];