Search code examples
cappuccinoobjective-j

Cannot add category to CPView Cappuccino


I am trying to add this category to CPView but XCodeCapp gives an error and I get unrecognized selector sent to instance error when I try to use this method.

@import <AppKit/CPView.j>

@implementation CPView (Custom)

- (void) addSomething
{
    var bounds = [self bounds];
    var context = [[CPGraphicsContext currentContext] graphicsPort];

    CGContextSetFillColor(context, [CPColor blueColor]);
    CGContextFillRect(context, CGRectMake(100,100,100,100));
}

@end

The syntax is correct as far as I can tell, the file name I am using is CPView_Custom.j

EDIT

I am also using IB to connect a CPView ivar to a custom view in the XIB/NIB file. Not sure if this makes a difference or not.


Solution

  • XCodeCapp will always throw errors regarding Categories because the objj CLI cannot understand them as a single file.

    You should ignore your categories by adding some entries in .xcodecapp-ignore.