ios - How to check for True or False on Objective C BOOL variable -
i have nsobject contains several objects couple of bool variables set either "t" or "f"
i know how use them in if statement looks this.
if (mynsobject.firstbool == t) { // stuff here }
i cannot , not sure why, can ask if true or yes not t have looked answers on other sites struggling find hoping might able offer insight.
any appreciated.
with bool
variables , properties, comparisons yes
/no
or true
/false
unnecessary. bool
valid boolean expression, can go if
, ternary ? :
, or loop construct without additional comparisons.
you can write this:
// use bool in if if (myobj.boolpropertyone) { // execute if boolpropertyone set true } // use bool in loop while (!myobj.boolpropertytwo) { // execute while boolpropertytwo set false } // use bool in conditional expression int res = myobj.boolpropertythree ? 18 : 42;
Comments
Post a Comment