开发者

How to use '||' in if-else statement in iphone appllication?

if((([txtFldO1.text length] == 0 ) || ([txtFldO2.text length] == 0 ) || 
([txtFldO3.text length] == 0 ) || ([txtFldO4.text length] == 0 ) || 
([txtFldO5.text length] == 0 )) &&am开发者_如何学Gop; (([txtFldR1.text length]== 0) || 
([txtFldR2.text length]== 0) || ([txtFldR3.text length]== 0) || ([txtFldR4.text length]== 0) || ([txtFldR5.text length]== 0)))
    {
             //alert
             //return
         }

This statement does not work. It does access all of the propeties. Could anyone tell me why? I need to access one txtFldO and one txtFldR.


To access properties, try SELF

self.txtFld00.text.length


It should be like this.

if([txtFldO1.text length] == 0 || [txtFldO2.text length] == 0 || [txtFldO3.text length] == 0 || [txtFldO4.text length] == 0){

// Code here 

}

You don't need to put parentheses before condition. Just put one parentheses like above example.

Hope this help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜