nicklockwood / XMLDictionary

[DEPRECATED]
http://charcoaldesign.co.uk/source/cocoa#xml-dictionary
Other
1.14k stars 235 forks source link

Problem with @attributes #8

Closed profburke closed 10 years ago

profburke commented 11 years ago

I haven't had a chance to dig into this yet, but when I try something like

[xmldoc valuForKeyPath:@"link.@attributes.rel"]

I get the following exception

*\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[<__NSDictionaryM 0x8979d40> valueForKeyPath:]: this class does not implement the attributes operation.'

I've tried a few variations with no luck. Although

[xmldoc valueForKeyPath:@"link._rel"]

works, so this is not a show-stopper.

nicklockwood commented 11 years ago

Hmm, that's curious. Does this work?

[xmldoc valuForKeyPath:@"link.attributes.rel"]
profburke commented 11 years ago

In the sense of not throwing an exception, yes :) But, it doesn't retrieve the attribute values.

nicklockwood commented 11 years ago

Huh. OK, I'll look into it.

HoloRin commented 11 years ago

the @ symbol is treated specially in value for key path, as it denotes a collection operator https://developer.apple.com/library/mac/documentation/cocoa/conceptual/KeyValueCoding/Articles/CollectionOperators.html

It might need to be escaped somehow if its supposed to be part of a key name.

nicklockwood commented 10 years ago

I'm afraid this was a misconception on my part. I've updated the documentation accordingly.