免费电话桥 [英] Toll free bridges
问题描述
作为iPhone开发的新手和过去几周的Objective-C,我在CF和NS框架之间遇到过多次提及免费桥接。
As a newcomer to iPhone development and Objective-C in general over the last few weeks I have come across numerous mentions of 'Toll free bridges' between CF and NS frameworks.
一个特定的例子是CFStream和NSStream。
One particular example would be CFStream and NSStream.
资源是否存在记录所有这些桥梁以及如何使用它们?它是否就像从一种类型的对象转换到另一种类型一样简单?
Does a resource exists documenting all of these bridges and how to use them ? Is it just as simple as casting from an object of one type to another ?
我问我目前正在使用iPhone内不严格允许的NSStream调用SDK并了解我应该使用CFStream调用。
I ask as at the moment I am using NSStream calls that are not stricly allowed within the iPhone SDK and understand that I should be using CFStream calls.
编辑:一篇关于 TFB如何运作
推荐答案
免费桥接意味着数据结构是可互换的。它就像铸造一样简单 - 这就是免费部分。您可以在桥的一侧使用该类型的任何地方,您可以使用另一个。因此,例如,您可以创建一个CFString,然后向其发送NSString消息,或者您可以创建一个NSArray并将该数组传递给CFArray函数。
Toll-free bridging means that the data structures are interchangeable. It is just as simple as casting — that's the "toll-free" part. Anyplace you can use the type on one side of the bridge, you can use the other. So, for example, you can create a CFString and then send NSString messages to it, or you can create an NSArray and pass the array to CFArray functions.
Apple保持一个其网站上支持的免费桥接类型列表。
Apple keeps a list of the supported toll-free bridged types on its site.
这篇关于免费电话桥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!