开发者

iOS/Objective-C - How to check if an enum is available?

I'm trying to test if a specific enum is available in the version of iOS runn开发者_StackOverflow社区ing on a device. I am using a specific enum that is not available in previous versions of the OS. I already know how to test for method availability by using respondsToSelector like this:

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

}

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


I don't think that you can directly check for an enum availability, but you don't actually need it.

Simply check for one selector availability that you know is available on the same iOS version that you know has got the enum you need. In other words, check for some selector that was added to iOS at the same time as the enum.

It is not actually the same, but I think it does reasonably what you need. If the selector you check for does use that enum, you are pretty close to the perfect solution.


There is no method to check for the availability of the enum at the runtime. Best method would be to check for iOS version or check for the feature that you would want to enable or provide depending on the iOS version. If you can tell us the feature, I'm sure someone out here will surely be able to help you out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜