CocoaDev

Edit AllPages

Here’s a simpe value transformer that lets you bind dictionaries to array controllers. The dictionary is transformed into an array of dictionaries with the keys ‘key’ and ‘value’. From my understanding of bindings it will require “Handles Content As Compound Value” for mutable dictionaries, but other than that there’s nothing to think about.

You are free to do as you wish with this code, and if your house burns down it’s not my fault etc etc..

@interface DictionaryToArrayTransformer : NSValueTransformer { }

@end @implementation DictionaryToArrayTransformer

@end

Mr. Fisk


For many situations, this may be too simplistic. See http://www.cocoabuilder.com/archive/message/cocoa/2005/8/19/144601.


Could anyone clarify when and why? From what I understand after reading that post, they merely achieve the same thing as using my transformer with the “Handle Content as Compound Value” binding option, only more efficient (the whole dictionary doesn’t get rewritten on every modification).