我在尝试将简单的浮点值设置为 1 时遇到了一个非常奇怪的问题。
我的财产:
{
float direction;
}
@property(nonatomic)float direction;
这是合成的:
@synthesize direction;
然后我使用了以下代码:
- (void)setDirection:(float)_direction {
NSLog(@"Setter called with value of %f",_direction);
self->direction = _direction;
}
出于测试目的...
当我尝试用这个改变值时,
[[w getCharacter] setDirection:1.0f];
哪里[w getCharacter]
给出了这个:
return [[[self scene] gameLayer] player];
我收到警告,“setDirection
未定义”。
如果我切换到点表示法([w getCharacter].direction
),我会“被早期的错误弄糊涂,退出”。
这就是奇怪的开始。当我尝试更改值时,调试消息显示_direction = 0.00000
. 当我稍后检查这个数字时,它仍然是 0.000。我显然试图将其更改为 1,为什么这不起作用?