Unable to add a category to a CPArrayController (cappuccino)
I'm trying to add a method to the CPArrayController class via a category. The template for adding reverse to the CPString works fine but I'm unable to add anything to the CPArrayController. While compiling I get the error
SyntaxError: * Could not find definition for class "CPArrayController"
Here is my code:
@impo开发者_Go百科rt <AppKit/CPArrayController.j>
@implementation CPArrayController (Inserting)
- (CPObject)insertAndReturn
{
if (![self canInsert]) return nil;
var newObject = [self automaticallyPreparesContent] ? [self newObject] : [self _defaultNewObject];
[self addObject:newObject];
return newObject;
}
@end
Any idea why ?
CPArrayController ist Part of AppKit.
So you need to import it, like :
@import <AppKit/CPArrayController.j>
@implementation CPArrayController (Inserting)
- (CPObject)insertAndReturn
{
if (![self canInsert]) return nil;
var newObject = [self automaticallyPreparesContent] ? [self newObject] : [self _defaultNewObject];
[self addObject:newObject];
return newObject;
}
@end
精彩评论