实现类:找不到超类

ila*_*pad 2 iphone objective-c superclass

我有ForceGaugeViewController类和ForceGaugeController类.我正在尝试使ForceGaugeController类成为ForceGaugeViewController的子类,但我收到错误.

错误:

无法找到ForceGaugeController类的ForceGaugeViewController超类的接口声明.

ForceGaugeViewController.h

#import <UIKit/UIKit.h>
#import <math.h>
#import "HardwareController.h"
#import "ForceGaugeController.h"

@interface ForceGaugeViewController : UIViewController{
}
end
Run Code Online (Sandbox Code Playgroud)

ForceGaugeViewController.m

#import "ForceGaugeViewController.h"

@implementation ForceGaugeViewController
Run Code Online (Sandbox Code Playgroud)

ForceGaugeController.h

#import <Foundation/Foundation.h>
#import "ForceGaugeViewController.h"
#import "FMDatabase.h"
#import "FMResultSet.h"

@class ForceGaugeViewController;

// error here
@interface ForceGaugeController : ForceGaugeViewController{
}
@end
Run Code Online (Sandbox Code Playgroud)

ForceGaugeController.m

#import "ForceGaugeController.h"
Run Code Online (Sandbox Code Playgroud)

Joe*_*Joe 7

您不仅可以转发引用将继承的类或将要实现的协议.您只需要在已经执行的标头中导入超类,然后删除@class声明.

编辑:此外,超类ForceGaugeViewController不应ForceGaugeViewController在头文件中包含子类.

ForceGaugeController.h

#import <Foundation/Foundation.h>
#import "ForceGaugeViewController.h"
#import "FMDatabase.h"
#import "FMResultSet.h"

@interface ForceGaugeController : ForceGaugeViewController{
 }
@end
Run Code Online (Sandbox Code Playgroud)


asa*_* am 5

确保避免循环导入: 确保不要将任何头文件或实现子类文件导入到超类接口声明为(.h文件)的超类文件中。