gpt4 book ai didi

ios - 如果需要声明建议

转载 作者:行者123 更新时间:2023-11-28 18:00:23 25 4
gpt4 key购买 nike

当在我的 UITextFieldrcdAtIan.text 中输入大于 200 的值时,我试图显示警报。我试过这个:

 Self.rcdAtIan.text = self.circuit.rcdAtIan;
if (_rcdAtIan.text > @"200");{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Value Exceeded" message:@"Message here............." delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[alert show];

然后是:

Self.rcdAtIan.text = self.circuit.rcdAtIan;
if (self.circuit.rcdAtIan > @"200");{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Value Exceeded" message:@"Message here.........." delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[alert show];
}

但警报是在加载 View 时显示的,而不是通过我的 if 语句显示的。我知道我想说什么 — if (_rcdAtIan.text => 200 "show my alert"); — 但我不确定语法是否正确。

最佳答案

您正在尝试对 2 个字符串值执行算术比较。你需要做的是问:

if ([_rcdAtIan.text intValue] > 200) {...

关于ios - 如果需要声明建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14293661/

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