Reputation: 151
It seems like I need key value coding. I have a bunch of bluetooth beacons, and when I get a signal from one I need to do something with a property. If the beacon is called Beacon5, then the property is called Beacon5path. I want to make
_Beacon5path.hidden = true
So I have a variable
NSString* myBeacon = @"Beacon5path"
And I can do
id value = [self valueForKey:myBeacon];
How do I then manipulate this?
I tried
value.hidden = true;
or _value.hidden = true;
But those don't do anything.
Upvotes: 0
Views: 58
Reputation: 31016
Since it's a UIView
that you want to hide, you can either test that it's the right kind of class and then cast it as a UIView
to keep the compiler happy or you can take a more general approach and check whether it's anything you can hide, such as:
if ([value respondsToSelector:@selector(setHidden:)]) {
[value setHidden:YES];
}
Upvotes: 1