本文介绍了Objective-C是否具有与Swift的@escaping注释等效的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Swift中,转义的闭包参数用@escaping
注释.在Objective-C中是否有任何等效项,以便将生成的Swift接口标记为@escaping
?
解决方案
是的,但是与您在问题中的建议相反.规则是,除非明确标记(NS_NOESCAPE ^)
,否则将Objective-C不可为空的块自动作为@escaping
函数 转换为Swift.
In Swift, escaping closure parameters are annotated with @escaping
. Is there any equivalent in Objective-C so that the generated Swift interfaces will be marked as @escaping
?
解决方案
Yes, but it's backwards from what you suggest in your question. The rule is that an Objective-C nonnullable block is translated into Swift as an @escaping
function automatically, unless it is explicitly marked (NS_NOESCAPE ^)
.
这篇关于Objective-C是否具有与Swift的@escaping注释等效的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!