If I have a method like:
@interface CharacterSet
+ (NSArray *)allCharacterSets;
@end
Can I bind to it using Cocoa bindings?
I’m trying to hook up an NSComboBox’s content values to it. When I enter CharacterSet.allCharacterSets into the “Model Key Path” field in IB, it doesn’t work, saying:
[
addObserver:
forKeyPath:@”CharacterSet.allCharacterSets”
options:0x0 context:0x200275b80] was
sent to an object that is not
KVC-compliant for the “CharacterSet”
property.
I’m not sure what else to try. Currently I have to store the return value of allCharacterSets into an ivar in my custom window controller (or custom window) to make it work, which seems like an extra step I shouldn’t have to take.
I’m working on a huge application and the extra steps you mentioned were really pain in the ass for me. So I developed a small proxy class that handles class method bindings.
First I’ve added a small proxy class
Then added a category accessor to NSApplication
(I actually added this to my application delegate and implemented application:delegateHandlesKey:)
Now you are ready to bind class methods to the Application object, even in the interface builder, with the keyPath
@"classProxy.CharacterSet.allCharacterSets".