2012-03-15 29 views
2

我想將此類別添加到CPView,但XCodeCapp提供了一個錯誤,當我嘗試使用此方法時出現unrecognized selector sent to instance錯誤。不能將類別添加到CPView卡布奇諾

@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伊娃連接到一個自定義在XIB/NIB文件中查看。不知道這是否有所作爲。

+0

你是如何導入它? – 2012-03-15 00:30:36

+0

'@import「CPView_Custom.j」'在AppController.j頂部 – 2012-03-15 00:32:15

+0

對我來說很好。嘗試將代碼移動到您使用它的文件中。如果有效,那麼問題將與導入相關。 – 2012-03-15 00:36:17

回答

1

XCodeCapp將始終拋出有關類別的錯誤,因爲objj CLI無法將它們理解爲單個文件。

您應該忽略您的類別,在.xcodecapp-ignore中添加一些條目。