Must I use __bridge or __bridge_retained if I'm bridging an autoreleased object to Core Foundation?

梦想与她 提交于 2019-12-03 14:55:39

You want to use the regular __bridge cast only for this. You would use __bridge_retained only if you want to manage the lifecycle of a cast CF object. For example:

CFStringRef cf_string = (__bridge_retained CFStringRef)someNSString;
// some long time later, perhaps in another method etc
CFRelease(cf_string);

So the __bridge_retained is really telling the compiler that you had an ARC object and now you want to basically turn it into a CF object that you're going to manage directly.

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