Macro to detect availability of class properties in Objective-C

这一生的挚爱 提交于 2019-12-12 15:04:29

问题


Xcode 8 introduces Objective-C class properties and I would like to add one to an Objective-C library.

However I would like the library to still compile with Xcode 7. Is there an availability check I can do at compile time?

Something like

#if __hasFeature(objc_class_properties)
@property (class, readonly, nonatomic) MySingletonClass *shared;
#endif

What does work is:

#if __clang_major__ >= 8

…but I'd like to check for feature availability rather than CLANG version.


回答1:


Searching the LLVM source code I found:

#if __has_feature(objc_class_property)

…which works perfectly.



来源:https://stackoverflow.com/questions/39131390/macro-to-detect-availability-of-class-properties-in-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!