CLLocationCooperative2D 不知道数组中有多少个?
我需要使用如下内容构建一个数组:
CLLocationCoordinate2D points[4];
points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116);
points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066);
points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981);
points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267);
问题是,我永远不会知道数组中有多少项,所以我可以指定计数。有没有办法创建一个 CLLocationCooperative2D 数组,并且只插入新坐标而不知道最终的总数是多少?
编辑:我的最终目标是使用坐标来制作 MKPolyline,使用需要 CLLocationCooperative2D 数组的 polylineWithCoordinates 方法。
I need to build an array using something like the following:
CLLocationCoordinate2D points[4];
points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116);
points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066);
points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981);
points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267);
Problem is, I will never know how many items are going to be in the array, so I can specify the count. Is there a way to create a CLLocationCoordinate2D array, and just insert new coordinates without knowing what the final total will be?
EDIT: My final goal is to use the coordinates to make an MKPolyline, using the polylineWithCoordinates method which needs a CLLocationCoordinate2D array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将它们放入
NSValue
对象中,然后将它们放入NSMutableArray
中。Box them up in an
NSValue
object and throw them in anNSMutableArray
.