0

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:

@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

Any idea why ?

Flavien Volken
  • 19,196
  • 12
  • 100
  • 133

1 Answers1

1

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
mafis
  • 1,165
  • 9
  • 17
  • Hi, oops I copied the wrong line (CPString instead of CPArrayController), I just corrected it. Actually even with the right import I get the compilation error. I placed the code block in the beginning of the AppController.j I really do not see what is wrong. – Flavien Volken Sep 15 '11 at 15:37
  • Just another question regarding to category (maybe it is the reason why I cannot get it work), what is the meaning of the "(Reversing)" in their category example "@implementation CPString (Reversing)" ? I proudly named it "(Inserting)" in mine but it is perhaps totally wrong… – Flavien Volken Sep 15 '11 at 15:58
  • The Description is only for you. (You can leave it blank and it change nothing) But now i think you use an old Cappuccino Version, which doesn't include CPArrayController. I upload an Example on Github with an actual Version of Cappuccino and it works like a charm : [CPArraycontroller Categorie Github](https://github.com/mafis/CPArraycontroller-Categorie-) – mafis Sep 15 '11 at 16:13
  • OK therefore it should be on my side… (or at least not a problem of the snippet itself). I will try to get the last version asap. Thank you for your help. – Flavien Volken Sep 16 '11 at 13:31