objective c - Cocoa Bindings and Checking for String content -
ok, here's want :
- let's have item, e.g.
nstextfield
- let's want bind
hidden
valuebool
variable - that's easy.
now, here's twist :
- i want bind
hidden
property check in fashion of (somestringvariable == "some string"
) - in few words : set element hidden when
somestringvariable
equal string.
how can within ib? doable?
well, duplicate of this question answered. other questioner has put bounty on one, so:
entirely within ib? no.
you can bind string-typed property , use custom value transformer convert string boolean according equality desired value.
however, it's easier add property class has string-typed property:
// assumed exist: @property (copy) nsstring* somestringproperty; + (nsset*) keypathsforvaluesaffectingshouldbehidden { return [nsset setwithobject:@"somestringproperty"]; } - (bool) shouldbehidden { return [self.somestringproperty isequaltostring:@"desired string"]; }
since property part of ui rather model, may wish define in category on model class. category declared , defined in controller code.
once it's defined, can bind shouldbehidden
property.
Comments
Post a Comment