On May 23, 2010, at 20:23, Dale Miller wrote:

> I need to use the parameters obtained from a plist (via 
> NSPropertyListSerialization). I can get the process to work quite well, 
> except that I have to use in my code an undocumented class: NSCFBoolean.
> Determining that the returned object is of class NSCFBoolean is the only way 
> I've been able to determine that I have a Boolean value. I can use the 
> objCType method of
> NSNumber to distinguish between integers and floats, but a BOOL is an 
> integer, which is IMHO a bad design decision. In some cases I can use a 
> priori knowledge to ask for
> the boolValue, but in a generalized case I'm forced to use (the name of) an 
> undocumented class (which was discovered by experimentation).
> I'd rather not have to go through a big learning curve to parse the raw XML, 
> and this to me is a big hole in the design.

It's not clear what the issue is here.

If you just need to know whether the value is YES or NO, you can simply ask for 
the numeric value (boolValue or one of the intValue siblings), and like 
everywhere else in Obj-C, non-zero means YES.

If you need to know whether the value is  *typed* boolean in the serialization, 
you're kind of barking up the wrong tree, because the type used to encode the 
value is an implementation detail, not part of the API (AFAIK). 'objCType' 
doesn't seem reliable -- "The returned type does not necessarily match the 
method the receiver was created with," says the documentation -- even for 
distinguishing between integers and floating point.

If, regardless, you must know the type of the object returned by the 
serialization, you just need to understand that all of the allowable types are 
toll-free bridged, so you can check for CFBoolean (which *is* documented, and 
of which NSCFBoolean is the underlying implementation) via CFGetTypeID.

Admittedly, it is a little strange that CFBoolean is toll-free bridged but 
there isn't any NSBoolean* type for it to be bridged into.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to