关于oc中的指针数组什么的在swift下提示不存在下标

qq_33707222 2017-08-01 04:03:36
in objective-c:
for (int j = 0; j < step.pointsCount; j++) {
BMKMapPoint pointarray;
pointarray.x = step.points[j].x; //这句话,其中的points在oc中是含下标【j】的,但在swift 中提示不应含下标
pointarray.y = step.points[j].y;
temppoints[k] = pointarray;
k++;
}
************************step***********************
@interface BMKRouteStep : NSObject{
int _distance;
int _duration;
BMKMapPoint* _points;
int _pointsCount;
}
///路段长度 单位: 米
@property (nonatomic) int distance;
///路段耗时 单位: 秒
@property (nonatomic) int duration;
///路段所经过的地理坐标集合
@property (nonatomic) BMKMapPoint* points;
///路段所经过的地理坐标集合内点的个数
@property (nonatomic) int pointsCount;

@end
**********************BMKMapPoint*******************
typedef struct {
double x; ///< 横坐标
double y; ///< 纵坐标
} BMKMapPoint;

希望大神帮忙解答一下!!!
...全文
224 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_33707222 2017-08-12
  • 打赏
  • 举报
回复
问题我大致解决了,其实主要是指针怎么操作,这个百度地图的swift demo中也有,谢谢楼上了
czrjdl 2017-08-10
  • 打赏
  • 举报
回复
10天前的问题啊, 估计你也解决了。 你得先把BMKRouteStep的定义转成Swift的形式啊,不然在swift中自然找不到数组了 ↓OC @interface BMKRouteStep : NSObject{ int _distance; int _duration; BMKMapPoint* _points; int _pointsCount; } ↓SWIFT struct BMKRouteStep { var _distance:Int var _duration:Int var _points: Array<BMKMapPoint> var _pointsCount:Int }

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧