[comp.lang.objective-c] How do you declare class categories which depend on each other?

hal@eecs.cs.pdx.edu (Aaron Harsh) (05/14/91)

  Is there some way to let the compiler know that a method will be declared
in another category?  On a class Foo defined like:
// Foo.h
#import <objc/Object.h>

@interface Foo : Object
{
}

- init;
@end

// Foo.m
#import "Foo.h"

@implementation Foo : Object
- init
{
    [self bar];

    return self;
}
@end

// Foo2.m
#import "Foo.h"

@interface Foo (Foo2)
- bar;
@end

@implementation Foo (Foo2)
- bar
{
    puts("BAR");
}
@end

  [[Foo alloc] init] gives the correct output, but the compiler gives the
warning: "Foo.m: warning `Foo' does not respond to `bar'".
  Adding '-bar' to the implementation declaration in Foo.h makes the compiler
complain about an incomplete declaration.  Does anyone know a way to split up
an object declaration without having it complain?

Aaron Harsh
hal@eecs.cs.pdx.edu