gpt4 book ai didi

objective-c - 您能在这段代码中看到什么错误吗? 'Cause I can’ t,但仍然无法正常工作

转载 作者:行者123 更新时间:2023-12-03 16:23:43 27 4
gpt4 key购买 nike

// When row is selected
- (void)pickerView:(UIPickerView *)pickerTimer didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
int minutes;
int seconds;

if (component == 0) {
if (row < 0){
minutes = row;
} else {
minutes = 0;
}
}
if (component == 1) {
if (row < 0){
seconds = row;
} else {
seconds = 0;
}
}
NSLog([NSString stringWithFormat:@"%f %f %d", minutes, seconds, row]);
if (minutes != 0 && seconds != 0){
[buttonTimer setTitle:[NSString stringWithFormat:@"%@ minutes and %@ seconds", minutes, seconds] forState:UIControlStateNormal];
// Yes, I am trying to set the label of a button.
}
if (minutes == 0 && seconds != 0){
[buttonTimer setTitle:[NSString stringWithFormat:@"%@ seconds", seconds] forState:UIControlStateNormal];
}
if (minutes != 0 && seconds == 0){
[buttonTimer setTitle:[NSString stringWithFormat:@"%@ minutes", minutes] forState:UIControlStateNormal];
}
if (minutes == 0 && seconds == 0){
[buttonTimerFarts setTitle:[NSString stringWithFormat:@"Set time before play starts..."] forState:UIControlStateNormal];
}

}

控制台将显示诸如
0.000000 -1.993950 2751746
前三个if(分钟秒)语句永远不会运行。

那么,您能看到任何错误吗?

最佳答案

在您的代码中,仅将row < 0minutesseconds设置为row。但是在您的示例中,row为正,因此minutesseconds仍然都是0,并且前三个if永远都不为真。

而且我对Objective-C不太了解,但是您正在用%f打印一个整数,这可能会给您带来胡扯。

关于objective-c - 您能在这段代码中看到什么错误吗? 'Cause I can’ t,但仍然无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2235170/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com