首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何创建CLLocationCoordinate2d对象

如何创建CLLocationCoordinate2d对象
EN

Stack Overflow用户
提问于 2013-06-26 16:28:00
回答 2查看 1.3K关注 0票数 0

我正在尝试调用MKPolylines的+ polylineWithCoordinates:count:方法。

在这种情况下,如何创建CLLocationCoordinate2D *对象。我已经在CLLocationCoordinate2D without knowing how many will be in the array?中看过了这个特殊的答案

代码语言:javascript
复制
// unpacking an array of NSValues into memory
CLLocationCoordinate2D *points = malloc([mutablePoints count] * sizeof(CLLocationCoordinate2D));
for(int i = 0; i < [mutablePoints count]; i++) {
[[mutablePoints objectAtIndex:i] getValue:(points + i)];
}

MKPolyline *myPolyline = [MKPolyline polylineWithCoordinates:points count:[mutablePoints count]];
free(points);

在上面的例子中,数组mutablePoints中是什么类型的条目?

EN

回答 2

Stack Overflow用户

发布于 2013-06-26 16:37:09

如果您的问题仅仅是数组中是哪种类型的条目,那么答案非常简单:NSValue条目。您可以查看此guide以了解有关如何使用NSValues的更多信息。

票数 0
EN

Stack Overflow用户

发布于 2013-06-26 16:42:19

代码语言:javascript
复制
CLLocationCoordinate2D coordinate;
    for (int i = 0; i < arr.count; i++)
    {
        float t1 = [[arr objectAtIndex:1] floatValue];
        float t2 = [[arr objectAtIndex:0] floatValue];

        coordinate.latitude = t1;
        coordinate.longitude = t2;

    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17315098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档