Sorry for the simple question but I feel like there's a smarter way to do this:
很抱歉这个简单的问题,但我觉得有一个更聪明的方法来做到这一点:
if ([txtFldTo.text length]>0){
//do something
}
else {
//do something else
}
where txtFldTo is an IBOutlet UITextField connected to a text field on the interface.
其中txtFldTo是连接到接口上文本字段的IBOutlet UITextField。
3 个解决方案
#1
Something like this should suffice.
这样的事情应该足够了。
if([[textfield text] length] > 0)
if([[textfield text] length]> 0)
#2
You're doing it right.
你做得对。
#3
if (![[textfield text] isEqualToString:@""]) {
}
or
if ([[textfield text] length] != 0) {
}
#1
Something like this should suffice.
这样的事情应该足够了。
if([[textfield text] length] > 0)
if([[textfield text] length]> 0)
#2
You're doing it right.
你做得对。
#3
if (![[textfield text] isEqualToString:@""]) {
}
or
if ([[textfield text] length] != 0) {
}