2

我正在尝试将此类别添加到 CPView 但 XCodeCapp 给出错误,并且unrecognized selector sent to instance当我尝试使用此方法时出现错误。

@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

据我所知,语法是正确的,我使用的文件名是 CPView_Custom.j

编辑

我还使用 IB 将 CPView ivar 连接到 XIB/NIB 文件中的自定义视图。不确定这是否有所作为。

4

1 回答 1

1

XCodeCapp 总是会抛出有关类别的错误,因为 objj CLI 无法将它们理解为单个文件。

您应该通过在 中添加一些条目来忽略您的类别.xcodecapp-ignore

于 2012-07-06T18:49:56.447 回答