Possible Duplicate:
cannot find interface declaration for ‘AbstractPickerView’,superclass of ‘AttackLayer’
There are 3 header files (a superclass and 2 subclasses):
// A.h
@interface A : NSObject
@end
// A1.h
#import "A.h"
@interface A1 : A
@end
// A2.h
#import "A.h"
@interface A2 : A
@end
I want to import all subclasses of class A.
So I added 2 #import in A.h like this:
// A.h
#import "A1.h" // added
#import "A2.h" // added
@interface A : NSObject
@end
But after adding them, the following compile errors occurred.
Cannot find interface declaration for 'A', superclas of 'A1'
Cannot find interface declaration for 'A', superclas of 'A2'
I know that this error can be solved by createing and importing the following file.
// ASubclasses.h
#import "A1.h"
#import "A2.h"
But I think #import A.h is more simple than #import ASubclasses.h to import subclasses.
And if I can use #import A.h to import subclasses, I don’t need to create another file(ASubclasses.h).
Is there a way to use #import A.h to import all subclasses of A?
Or in general, how do you import all subclasses of a class?
The error you’re getting is because of an #import cycle . This happens when two header files import each other . You can just declare the class using @class and then import the headerfile in the implementation file.