I have created a subclass of NSView to draw an image as a pattern:
@interface CePatternView : NSView
{
NSImage* image;
id observableObjectForImage;
NSString* keyPathForImage;
}
@end
I implemented the following to expose bindings:
+ (void)initialize
{
// Expose the "image" binding to IB.
[self exposeBinding:@"image"];
}
- (Class)valueClassForBinding:(NSString *)binding
{
if([binding isEqualToString:@"image"])
return [NSImage class];
return nil; // Unknown binding
}
Unfortunately, the image binding does not show up in Interface Builder.
Do I really have to create an IBPlugin to expose bindings in Interface Builder? That just seems way overkill for a custom view that I don't plan to reuse.
Answer to title: No, you can bind a custom view without an IB plug-in (by doing it in code).
Answer to question in question body: Yes, you do need an IB plug-in to expose the binding in IB.
Your code doesn't run inside Interface Builder unless you put it into Interface Builder, and that exposeBinding:
message is your code. Therefore, you need to put it into Interface Builder. That means writing an IB plug-in.
Also, IB plug-ins are not the same as the old IB palettes. Plug-ins require IB 3 and are much easier to create. Palettes require IB 2 and were painful to create.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With