views:

239

answers:

1

The following statement is taken from the CFMutableDictionary Reference section of the Mac OS X Reference Library:

CFMutableDictionary is “toll-free bridged” with its Cocoa Foundation counterpart, NSMutableDictionary. What this means is that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. This means that in a method where you see an NSMutableDictionary * parameter, you can pass in a CFMutableDictionaryRef, and in a function where you see a CFMutableDictionaryRef parameter, you can pass in an NSMutableDictionary instance. This also applies to concrete subclasses of NSMutableDictionary. See Interchangeable Data Types for more information on toll-free bridging.

Can someone please translate this into plain English? :-)

+7  A: 

It means that everyplace you see NSMutableDictionary you can use CFMutableDictionary, and vice versa, without having an explicit conversion.

Since a concrete subclass of NSMutableDictionary IS A NSMutableDictionary, they also can be used anyplace CFMutableDictionary is used.

Basically a roundabout way of saying that the types can be implicitly converted between each other.

This link has some more information.

Alan
I this completely true? Whenever you requests a `NSMutableDictionary`, what you get is a `NSCFMutableDictionary`. `NSMutableDictionary` is just an _abstract_ base class for the class cluster, and `NSCFMutableDictionary` is the concrete subclass. I believe that subclassing `NSMutableDictionary` will create a sibling to `NSCFMutableDictionary` that does not have the toll-free bridge parts.
PeyloW
PeyloW: you are mistaken.
Ahruman
Be aware that if you create a CFDictionary or CFMutableDictionary with out the retain/release callbacks, it can't be toll-free bridged.
Jonathan Dann