![](/img/trans.png)
[英]Objective C error with replaceObjectAtIndex - Thread 1: EXC_BAD_ACCESS (code=1, address=)
[英]Objective C - ERROR: Thread 1: EXC_BAD_ACCESS code=2
我在尝试调用方法时遇到错误。
方法
- (void)setSpeed:(GLKVector2)newSpeed{ //Error message (see title) points to here
self.speed = GLKVector2Make(newSpeed.x, newSpeed.y);
}
电话
[self setSpeed:GLKVector2Make(0, 0)];
有什么想法吗?
试着写
_speed = GLKVector2Make(newSpeed.x, newSpeed.y);
要么
speed = GLKVector2Make(newSpeed.x, newSpeed.y);
代替
self.speed = GLKVector2Make(newSpeed.x, newSpeed.y);
self.speed=
使用为其选择的任何访问器设置speed
属性。 名为“speed”的属性的setter的默认名称是setSpeed:
. 这是你正在使用的方法,它只是一遍又一遍地自我调用,永不停止。 您想直接设置实例变量(如果您只有@property
声明并且没有显式的@synthesize
,那么这将是_speed
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.