【发布时间】:2013-04-10 16:12:43
【问题描述】:
我有这个可可触摸代码,你按下一个按钮,一个 NSInteger 用数字 1 添加它自己,然后一个标签变成 NSInteger 值
这是代码
- (IBAction)out:(id)sender {
outnum = outnum + 1;
self.outnumberlabel.text = [[NSString alloc] initWithFormat: @"%d", outnum];
一切正常,但 NsInteger 在添加 1 时会添加 4
当我放入时
outnum = outnum + 2;
标签变成8
四分五裂有谁知道为什么以及如何解决它
【问题讨论】:
-
out的初始值是多少? -
out的初始值为0
-
你确定,这个动作被调用了一次?
-
是的,我只是用 Nslog 检查那里
-
不寻常,尝试将方法名称更改为
out以外的其他名称
标签: xcode cocoa-touch math nsinteger