• 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: CFPropertyList and NSDictionary/CFDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFPropertyList and NSDictionary/CFDictionary


  • Subject: Re: CFPropertyList and NSDictionary/CFDictionary
  • From: Chris Kane <email@hidden>
  • Date: Sat, 20 Dec 2003 14:31:54 -0800

On Nov 28, 2003, at 11:21 AM, Christopher Corbell wrote:
Is there any toll-free way to get from a CFPropertyListRef to an NSDictionary
(or CFDictionary) and back? I think I can probably use intermediate
NSData/CFDataRef to pass the raw XML data to and from a CFPropertyList and
a corresponding NSData object, but this seems inelegant to me - it's
a non-toll-free bridge between two redundant implementations of roughly
the same functionality. It seems like everything that CFPropertyList does
could have been added as a small extension to NSDictionary / CFDictionary.

If the top-level CFPropertyListRef is a CFDictionaryRef, you can just cast, and otherwise, no amount of going through XML machinery is going to help.

You can verify the CFPropertyListRef you got is a CFDictionaryRef with something like:

if (CFGetTypeID(plistRef) == CFDictionaryGetTypeID()) {
success ...
CFDictionaryRef myDict = (CFDictionaryRef)plistRef;
...
} else {
not a dictionary as expected ...
}

PLists which are dictionaries are a subset of all possible kinds of CFDictionarys, so the casting is valid. A cast to NSDictionary would also be valid for the same reason. The Cocoa equivalent to the CFPropertyList stuff can be found in NSPropertyList.h in 10.2 and later.


Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: What is the equivallent of CFMessagePortRef in Cocoa?
  • Next by Date: Splash screens (last message never went through)
  • Previous by thread: Re NSConnection on same machine between different users (via 10.3 fast switching)
  • Next by thread: Splash screens (last message never went through)
  • Index(es):
    • Date
    • Thread