ckruse / CFPropertyList

Read, write and manipulate both binary and XML property lists as defined by apple
MIT License
212 stars 47 forks source link

Symbols in arrays #36

Closed kenn closed 9 years ago

kenn commented 9 years ago

Symbols are handled as String when used as Dictionary keys, but not in an Array. Is there any specific reason that CFPropertyList does not support it?

I'm converting a hash to an array of arrays because Dictionary type in Obj-C / Swift is not ordered. I believe it would be a typical use case to do something like {small: 'Small', large: 'Large'}.to_a.

data = [["Large", :large],["Small", :small]]
plist = CFPropertyList::List.new
plist.value = CFPropertyList.guess(data)

CFTypeError: Unknown class Symbol. Try using :convert_unknown_to_string if you want to use unknown object types!
ckruse commented 9 years ago

No specific reason. I will add support for it. In the meantime you can use CFPropertyList.guess(data, :convert_unknown_to_string => true) as a work-around.

kenn commented 9 years ago

Ah, nice! Thank you for the great tool. :+1: