宏来检测Objective-C中类属性的可用性 [英] Macro to detect availability of class properties in Objective-C

查看:290
本文介绍了宏来检测Objective-C中类属性的可用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode 8引入了Objective-C类属性,我想向Objective-C库添加一个。

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

但是我想让库仍然用Xcode 7编译。有可用性检查我可以在编译时做吗?

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

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

这是什么工作:

#if __clang_major__ >= 8

...但我想检查功能可用性,而不是CLANG版本。

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

推荐答案

搜索 LLVM源代码我发现:

#if __has_feature(objc_class_property)

...。

这篇关于宏来检测Objective-C中类属性的可用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆