I have ForceGaugeViewController class and ForceGaugeController class. I'm trying to make the ForceGaugeController class be a subclass of ForceGaugeViewController, but I'm receiving errors.
Error:
Cannot find interface declaration for ForceGaugeViewController superclass of ForceGaugeController class.
ForceGaugeViewController.h
#import <UIKit/UIKit.h>
#import <math.h>
#import "HardwareController.h"
#import "ForceGaugeController.h"
@interface ForceGaugeViewController : UIViewController{
}
end
ForceGaugeViewController.m
#import "ForceGaugeViewController.h"
@implementation ForceGaugeViewController
ForceGaugeController.h
#import <Foundation/Foundation.h>
#import "ForceGaugeViewController.h"
#import "FMDatabase.h"
#import "FMResultSet.h"
@class ForceGaugeViewController;
// error here
@interface ForceGaugeController : ForceGaugeViewController{
}
@end
ForceGaugeController.m
#import "ForceGaugeController.h"
You can not only forward reference a class that you will inherit from or a protocol that you will implement. You just need to import the superclass in the header which you are already doing and then remove the @class
declaration.
Edit: Also the superclass ForceGaugeViewController
should not include the subclass ForceGaugeViewController
in the header file.
ForceGaugeController.h
#import <Foundation/Foundation.h>
#import "ForceGaugeViewController.h"
#import "FMDatabase.h"
#import "FMResultSet.h"
@interface ForceGaugeController : ForceGaugeViewController{
}
@end