2

I have an iPhone app with a custom class, Detail, a subclass of UIViewController that I created.

I need to make a subclass of Detail, and I want to to call it ActivityDetail. So I wrote the following in my ActivityDetail.h file:

#import <UIKit/UIKit.h>
#import "Detail.h"

@interface ActivityDetail : Detail {

}

@end

The problem is that I'm getting a compiler error telling me this:

error: cannot find interface declaration for 'Detail', superclass of 'ActivityDetail'

And the strange thing is: I can change the superclass from Detail to UIView (for example), compile getting many errors (obviously), and then change the superclass to Detail again and everything works fine! But if I then change anything to the Detail class the problem comes back from the beginning...

How can I solve this?

The Guardian
  • 374
  • 1
  • 7
  • 22
Abramodj
  • 5,709
  • 9
  • 49
  • 75

4 Answers4

8

Erm you are importing Detail as Dettaglio.h. Probably the compiler is not fluent in Italian.

Jano
  • 62,815
  • 21
  • 164
  • 192
8

It is recommended to not import classes beyond the default Foundation or UIKit imports in your header files. Instead you should do something similar:

Header

#import <UIKit/UIKit.h>

@class Detail;

@interface ActivityDetail : Detail {

}

@end

Implementation

#import "ActivityDetail.h"
#import "Detail.h"

@implementation ActivityDetail

@end

This allows your header to "know" about additional classes without forcing all "importers" of that header to also import everything it imports.


Here is a great reference question, and a great answer, regarding the usage of @class and #import.

Community
  • 1
  • 1
Ryan Wersal
  • 3,210
  • 1
  • 20
  • 29
0

Are you importing the .h where Detail is declared?

  #import "Detail.h"
Lou Franco
  • 87,846
  • 14
  • 132
  • 192
0

Either #import "Detail.h" or subclass from Dettaglio (depends on whichever one your Detail class is actually named.

Sid
  • 9,508
  • 5
  • 39
  • 60