IOS / Objective-C - How to check if an enumeration is available?

I am trying to check if a specific enumeration is available in the version of iOS running on the device. I use a specific enumeration that is not available in previous versions of the OS. I already know how to check the availability of a method using responsesToSelector as follows:

if ([self respondsToSelector:@selector(method:)]) { } 

Is there a similar test for listings? If not, how can I check it?

+6
source share
2 answers

I don’t think you can directly check for renaming, but you really don’t need it.

Just check for one selector availability, which, as you know, is available on the same version of iOS, which, as you know, got the listing you need. In other words, check out some selector that was added to iOS at the same time as the listing.

This is actually not the same, but I think that it does what you need. If the selector you check uses this enumeration, you're pretty close to perfect solutions.

+3
source

There is no way to check for an enumeration at runtime. The best way is to check the version of iOS or check the function that you want to enable or provide depending on the version of iOS. If you can tell us this feature, I’m sure that one of you will certainly be able to help you.

+1
source

Source: https://habr.com/ru/post/891295/


All Articles