ios - Syntax for "or" & "and" statements -
what proper syntax putting , & or statements?
i trying implement code validate data user inputting. have segmented control, text view , next page button. advance next view controller user must choose "yes" or "no" on segmented control , if yes selected must enter text text view.
- (ibaction)nextpagebutton:(uibarbuttonitem *)sender { if (weatherdelaystring == nil || ([weatherdelaystring isequal: @"yes"] && weatherdelaytextview.text == nil)) { nslog(@"nothing selected"); }else{ vc7signature *vc7 = [[vc7signature alloc]initwithnibname:nil bundle:nil]; [self presentviewcontroller:vc7 animated:yes completion:nil]; }}
could clarify syntax required implement logic?
why not de-mangle / de-tangle code rid of of , & or cases. can 1 single and:
- (ibaction)nextpagebutton:(uibarbuttonitem *)sender { if ([weatherdelaystring isequal: @"yes"] && ([weatherdelaytextview.text length] > 0)) { vc7signature *vc7 = [[vc7signature alloc]initwithnibname:nil bundle:nil]; [self presentviewcontroller:vc7 animated:yes completion:nil]; } else { nslog(@"the yes / next condition want users have go forward isn't selected"); } }
which easier read or plus nested , conditional.
Comments
Post a Comment