macos Objective-C中的正常铸造与桥梁铸造

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10834522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 09:12:49  来源:igfitidea点击:

Normal casting vs bridge casting in Objective - C

objective-ciosmacosios4xcode4.3

提问by TeaCupApp

What is the different between,

有什么不同,

(CFDataRef) data

&

&

(__bridge CFDataRef) data

Xcode asked me to change it to bridge. Is that because of ARC?

Xcode 要求我将其更改为桥接。是因为ARC吗?

回答by Mike Weller

Yes, ARC needs to be given instructions when you cast between toll-free bridged types. In this case __bridgetells ARC to do nothing, so this will behave the same as the previous standard cast.

是的,当您在免费桥接类型之间进行转换时,需要向 ARC 提供说明。在这种情况下,__bridge告诉 ARC 什么都不做,所以这将与之前的标准强制转换相同。

You can read the Transitioning to ARC Release Notesfor more details on the different ways to do bridging casts.

您可以阅读过渡到 ARC 发行说明,了解有关进行桥接转换的不同方法的更多详细信息。