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)
您不仅可以转发引用将继承的类或将要实现的协议.您只需要在已经执行的标头中导入超类,然后删除@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)
| 归档时间: |
|
| 查看次数: |
6616 次 |
| 最近记录: |