【发布时间】:2011-08-05 16:18:39
【问题描述】:
还有一些重构(为两个不同的类编写一个基类+其他一些东西),我的项目在 ipad 上编译失败,在模拟器上不能正常工作
/Users/.../PaintViewController.m:50: error: 'width' undeclared (first use in this function)
/Users/.../PaintViewController.m:59: error: 'backgroundView' undeclared (first use in this function)
当然,这些变量是声明的(在新的基类中),并且 2 个类继承自基类
任何想法为什么?我也导入了基类。
发生错误的类:
#import "PaintViewControllerBase.h"
@class PopupSaveDrawingController;
@interface PaintViewController : PaintViewControllerBase
{
MenuBarViewController *menuBarView;
bool bBarIsOpened;
bool bIsClosing;
bool bIsOpening;
float fBarY;
NSTimer *toggleTimer;
NSArray *toolBrushImgArray;// liste des textures de brosses
PopupSaveDrawingController *popupSaveDrawning;
}
基类:
@interface PaintViewControllerBase : UIViewController
{
// Handle Move ///
CGPoint location;
CGPoint previousLocation;
BOOL firstTouch;
// Size ///
NSInteger width;
NSInteger height;
// Actions
UndoRedoManager *undoManager;
toolType currentToolType;
// Brush
PaintBrush *brush;
PaintImage *image;
// image buffer //////
NSMutableData *data;
// GUI
PaintCanvas *backgroundView;
PaintCanvas *modeleView;
PaintCanvas *drawView;
}
编译失败的语句:
width = [PaintMenuViewController width]; // error here on ipad target only
height = [PaintMenuViewController height];// error here on ipad target only
CGRect rect = CGRectMake(0,0,width,height);
self.view = [[UIView alloc] initWithFrame:rect];
/**********************
* IMAGEVIEW BACKGROUND
**********************/
backgroundView = [[PaintCanvas alloc] initWithFrame:rect]; // error here on ipad target only
如果我在每个变量之前添加self,问题似乎就消失了,例如:self.width = 1024,但我不想这样做(有很多东西要改变)
【问题讨论】:
-
你应该发布基类的定义+编译失败的语句...
-
@sergio : 我添加了更多细节
标签: ios ipad compilation base-class