JSA*_*986 0 cocoa-touch objective-c ios
我想,当我输入大于200的值,显示一个警告UITextField,rcdAtIan.text.我试过这个:
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];
Run Code Online (Sandbox Code Playgroud)
然后这个:
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];
}
Run Code Online (Sandbox Code Playgroud)
但是加载视图时会显示警报,而不是我的if声明.我知道我想说的是什么if (_rcdAtIan.text => 200 "show my alert");- 但我不确定正确的语法.
您正尝试对2个字符串值执行算术比较.你需要做的是问:
if ([_rcdAtIan.text intValue] > 200) {...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64 次 |
| 最近记录: |