FROM : glenn andreas
DATE : Thu Mar 27 17:22:18 2008
On Mar 27, 2008, at 10:59 AM, Sherm Pendley wrote:
>>> CFBoolean *is* toll free bridged to NSNumber.
>
>
> OK, so where is that documented then? As I said, the CFBoolean
> reference
> says not a word about it:
It's more subtle than that.
CFNumber is toll-free bridged with NSNumber.
"toll-free bridged" things need to work both ways - where you can use
one, you can use the other.
If CFBoolean were toll-free bridged with NSNumber then you can use an
NSNumber where you can use a CFBoolean. But since you can also use a
CFNumber where you can use an NSNumber, this would mean that you can
use a CFNumber where there is a CFBoolean, which you can't.
CFBoolean is instead just "partially bridged". You can use
kCFBooleanTrue wherever you can use [NSNumber numberWithBool: YES] and
kCFBooleanFalse wherever you can use [NSNumber numberWithBool: NO] (in
that CFBoolean has enough scaffolding to support NSNumber routines,
and CFBooleanGetValue understands NSNumber).
This does not imply that [NSNumber numberWithBool: YES] ==
kCFBooleanTrue (it may be, but that's not documented as such), just
that they are interchangeable.
For example, from <http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#//apple_ref/doc/uid/20001010-BBCBDBJE
>
> Cocoa property lists organize data into named values and lists of
> values using these classes:
>
> •NSArray
> •NSDictionary
> •NSData
> •NSString (java.lang.String in Java)
> •NSNumber (subclasses of java.lang.Number in Java)
> •NSDate
>
> The Core Foundation property list API, defined in <CoreServices/
> CoreServices.h>, supports the following Core Foundation types:
>
> •CFArray
> •CFDictionary
> •CFData
> •CFString
> •CFDate
> •CFNumber
> •CFBoolean
> Because all these types can be automatically cast to and from their
> corresponding Cocoa types, you can use the Core Foundation property
> list API with Cocoa objects. In most cases, however, methods
> provided by theNSPropertyListSerialization class should provide
> enough flexibility.
>
>
So it is documented that they can be automatically cast to and from
their corresponding Cocoa types (assuming you're willing to grant that
NSNumber is the corresponding type for CFBoolean, but they do say
_all_ of the types, and if it's not NSNumber, there's no clear other
candidate).
Glenn Andreas <email_removed>
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
DATE : Thu Mar 27 17:22:18 2008
On Mar 27, 2008, at 10:59 AM, Sherm Pendley wrote:
>>> CFBoolean *is* toll free bridged to NSNumber.
>
>
> OK, so where is that documented then? As I said, the CFBoolean
> reference
> says not a word about it:
It's more subtle than that.
CFNumber is toll-free bridged with NSNumber.
"toll-free bridged" things need to work both ways - where you can use
one, you can use the other.
If CFBoolean were toll-free bridged with NSNumber then you can use an
NSNumber where you can use a CFBoolean. But since you can also use a
CFNumber where you can use an NSNumber, this would mean that you can
use a CFNumber where there is a CFBoolean, which you can't.
CFBoolean is instead just "partially bridged". You can use
kCFBooleanTrue wherever you can use [NSNumber numberWithBool: YES] and
kCFBooleanFalse wherever you can use [NSNumber numberWithBool: NO] (in
that CFBoolean has enough scaffolding to support NSNumber routines,
and CFBooleanGetValue understands NSNumber).
This does not imply that [NSNumber numberWithBool: YES] ==
kCFBooleanTrue (it may be, but that's not documented as such), just
that they are interchangeable.
For example, from <http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#//apple_ref/doc/uid/20001010-BBCBDBJE
>
> Cocoa property lists organize data into named values and lists of
> values using these classes:
>
> •NSArray
> •NSDictionary
> •NSData
> •NSString (java.lang.String in Java)
> •NSNumber (subclasses of java.lang.Number in Java)
> •NSDate
>
> The Core Foundation property list API, defined in <CoreServices/
> CoreServices.h>, supports the following Core Foundation types:
>
> •CFArray
> •CFDictionary
> •CFData
> •CFString
> •CFDate
> •CFNumber
> •CFBoolean
> Because all these types can be automatically cast to and from their
> corresponding Cocoa types, you can use the Core Foundation property
> list API with Cocoa objects. In most cases, however, methods
> provided by theNSPropertyListSerialization class should provide
> enough flexibility.
>
>
So it is documented that they can be automatically cast to and from
their corresponding Cocoa types (assuming you're willing to grant that
NSNumber is the corresponding type for CFBoolean, but they do say
_all_ of the types, and if it's not NSNumber, there's no clear other
candidate).
Glenn Andreas <email_removed>
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
| Related mails | Author | Date |
|---|---|---|
| Lorenzo | Mar 26, 17:51 | |
| Laurent Cerveau | Mar 26, 18:02 | |
| Jean-Daniel Dupas | Mar 26, 18:07 | |
| Lorenzo | Mar 26, 21:02 | |
| Nick Zitzmann | Mar 26, 21:17 | |
| Laurent Cerveau | Mar 26, 21:29 | |
| Jonathan Hess | Mar 26, 21:41 | |
| Lorenzo | Mar 27, 00:04 | |
| Sherm Pendley | Mar 27, 00:48 | |
| Clark Cox | Mar 27, 16:25 | |
| Clark Cox | Mar 27, 16:29 | |
| Sherm Pendley | Mar 27, 16:59 | |
| Matt Gough | Mar 27, 17:18 | |
| Jean-Daniel Dupas | Mar 27, 17:19 | |
| glenn andreas | Mar 27, 17:22 | |
| Sherm Pendley | Mar 27, 17:33 | |
| Scott Thompson | Mar 27, 21:39 | |
| Lorenzo | Apr 28, 09:31 | |
| Nick Zitzmann | Apr 28, 09:34 | |
| Lorenzo | Apr 28, 09:48 | |
| Jean-Daniel Dupas | Apr 28, 09:58 | |
| Jean-Daniel Dupas | Apr 28, 10:58 | |
| Michael Vannorsdel | Apr 28, 18:58 |






Cocoa mail archive

