【问题标题】:How to create a CLLocationCoordinate2d object如何创建 CLLocationCoordinate2d 对象
【发布时间】:2013-06-26 08:28:00
【问题描述】:

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

在这种情况下如何创建 CLLocationCoordinate2D * 对象。我在CLLocationCoordinate2D without knowing how many will be in the array?

中完成了这个特定的答案
// 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 中有哪些条目?

【问题讨论】:

    标签: iphone ios cllocationmanager


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:
      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;
      
          }
      

      【讨论】:

      • 这与OP的问题没有任何关系!
      猜你喜欢
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 2017-10-28
      • 2018-07-21
      • 2011-03-17
      • 2019-03-24
      • 2013-06-23
      相关资源
      最近更新 更多