我正忙着弄清楚如何检测UITextfield文本的数值是否大于52?
我尝试使用NSScanner
但没有运气。
NSScanner * scanner = [NSScanner scannerWithString:self.repeatOccurrenceFrequencyWeeklyTF.text];
double val;
[scanner scanDouble:&val];
// Scanned the whole string and ended up with a positive value
if( [scanner isAtEnd] && val > 52 ){
NSLog(@"'%@'? I accept.", self.repeatOccurrenceFrequencyWeeklyTF.text);
}
else {
NSLog(@"'%@' is no good.", self.repeatOccurrenceFrequencyWeeklyTF.text);
[self showMessage:@"Week Error" Message:@"The week field must be filled in."];
}
答案 0 :(得分:3)
您可以将texField
转换为int
这样的值:
int changeid = [idchoice.text intValue];
将此int
值与52