One way is to create a data structure matching the classes you like in enum . This will be a lot of boiler plate code.
Unfortunately, Objective-C does not have object-oriented switch conditional languages ββsuch as Ruby. It has only a C switch . A case in a C switch requires an integer constant, and this prevents more dynamic approaches using C switch . The enum C type also works with constants. This means that none of them can be generated at runtime, but can be at compile time.
Enumeration operators and C switches work well together, but not so hot for objects.
So, you might be better off making if-else compound expressions to do your comparisons here.
source share