If the filter value can only be a small, constant number of things, just use an enumeration and a switch statement:
enum Filter { ColorFilter, FooFilter, BarFilter }; - (void)filterSelected:(Filter)filter { switch(filter) { case ColorFilter: self.colorFilter = ...; break; case FooFilter: self.fooFilter = ...; break; case BarFilter: self.barFilter = ...; break; } }
If the set of filter values โโis large and can change frequently, you can also use Key-Value Coding . It is more complicated, but more flexible.
source share