views:

467

answers:

2

I'm creating an Interface Builder plugin for an NSView subclass. I've been following the Interface Builder Plug-in Programming Guide but it's not answer all my questions. My class has one NSString property and 4 NSColor properties which I want to create bindings for at design time.

I can't figure out where the bindings are specified in the plugin project. The documentation states that the Inspector Object is only for creating the Attribute Inspector. The class description file (.classdescription) lists outlets and actions but not bindings.

Where do I specify the bindings for my class?

+3  A: 

In your class initializer, make a call to + (void)exposeBinding:(NSString *)binding as follows:

+ (void)initialize
{
    [self exposeBinding:@"someProperty"];
}

You may also want to specify the value class as follows:

- (Class)valueClassForBinding:(NSString *)binding
{
    if ([binding isEqual:@"someProperty"])
    {
        return [NSNumber class];
    }
    else
    {
        return [super valueClassForBinding:binding];
    }
}

Take a look at this CocoaDev article and Apple's NSKeyValueBindingCreation Protocol Reference

e.James
A: 

I'm trying to implement this but I'm having some trouble, can you post some example project please?

Thanks

andres