嗨,对于这样一个愚蠢的问题,我很抱歉,我正在根据分段控件的索引更改变量值,但随后想在随后的计算中使用该变量;确定这与变量范围有关吗?
- (IBAction)calculate:(UIButton *)button {
if( [sSeg selectedSegmentIndex]==1){
float s=0.5;
NSLog(@"s=%f", s);
}
else if ([sSeg selectedSegmentIndex]==0)
{
float s=1;
NSLog(@"s=%f", s);
}
NSLog(@”s now = %f”, s);
}
非常感谢帮助!