• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PList Data Typing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PList Data Typing


  • Subject: Re: PList Data Typing
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 15 Dec 2014 16:40:37 -0600

On Dec 15, 2014, at 4:10 PM, Kevin Bracey <email@hidden> wrote:

> I'm needing to read in a PList, that others have designed, I have no control over the input.
>
> One of the Keys stores either a String, Number or Boolean value.
>
> Checking for the NSString is straight forward.
>
> How can I tell if the Value is a Boolean or Number in the NSDictionary? as 0 and 1 are valid values for a number.

In Cocoa, both booleans and numbers are represented by NSNumber.

In Core Foundation, there are distinct types, CFBoolean and CFNumber.

NSNumber and CFNumber are toll-free bridged, but there's no similar guarantee about NSNumber and CFBoolean.

The most reliable solution may be to use Core Foundation to deserialize the property list.  See CFPropertyList <https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFPropertyListRef/index.html>.  For any given object in the resulting property list, you can check its type using the standard mechanism for CFTypes.  Call CFGetTypeID() on the object and then compare the result to CFBooleanGetTypeID(), CFNumberGetTypeID(), etc.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


References: 
 >PList Data Typing (From: Kevin Bracey <email@hidden>)

  • Prev by Date: Re: PList Data Typing
  • Next by Date: Re: Using AV Foundation to record m3u8 stream to disk
  • Previous by thread: Re: PList Data Typing
  • Next by thread: Issues with applications running on background (Alarm Application)
  • Index(es):
    • Date
    • Thread