我有一个相当紧迫的问题,我找不到答案。我正在尝试在 iPhone 应用程序中使用谷歌地图 API 绘制当前位置和目的地之间的路径。我从谷歌获取数据,解析没有错误的 JSON,解码折线,然后我有这个方法:
-(void) loadRouteWithPoints:(NSArray *) routes
{
CLLocationCoordinate2D coords[[routes count]];
for(int i = 0; i < routes.count; i++)
{
CLLocation* loc = (CLLocation*)[NSKeyedUnarchiver unarchiveObjectWithData:[routes objectAtIndex:i]];
CLLocationCoordinate2D c;
c.latitude = loc.coordinate.latitude;
c.longitude = loc.coordinate.longitude;
coords[i] = c;
}
MKPolyline *line = [MKPolyline polylineWithCoordinates:(CLLocationCoordinate2D*)coords count:[routes count]];
[self.mapsView addOverlay:line];
}
这会引发异常[NSKeyedUnarchiver unarchiveObjectWithData:[routes objectAtIndex:i]];
:
“-[CLLocation 字节]:发送到实例的无法识别的选择器”
我作为参数发送的数组是我在解码折线后得到的数组,它不是 nil ,它有 - 在我的测试中 - 47 个值。我可以看到它们,每个条目如下所示:
<+44.47874069,+26.10523033> +/- 0.00m(速度 -1.00 mps / 路线 -1.00)@ 2012 年 6 月 29 日 17:09:37 东欧夏令时间
您是否知道可能导致此崩溃的原因以及如何解决?