类的子类超类
我试图让两个子类:类的子类超类
// Old code
- (void)setPaging {
[pagingScrollView addSubview:self.ImageScrollView];
}
@interface ImageScrollView : UIScrollView <UIScrollViewDelegate> {
UIView *imageView;
NSUInteger index;
}
@property (assign) NSUInteger index;
- (void)displayTiledImageNamed:(CGPDFPageRef)page size:(CGSize)imageSize;
@end
@implementation ImageScrollView
@synthesize index;
// ... my methods ...
@end
更改为:
// NEW Code__________________________________________________________*
- (void)setPaging {
if (D == 1) {
// error: request for member 'ISVportrate' in something not a
// structure or union
[pagingScrollView addSubview:self.ISVportrate];
} else if (D == 2) {
//error: request for member 'ISVLandscape' in something not a
// structure or union
[pagingScrollView addSubview:self.ISVLandscape];
}
}
@class ISVportrate;
@class ISVLandscape;
@interface ImageScrollView : UIScrollView <UIScrollViewDelegate> {
UIView *imageView;
NSUInteger index;
}
@property (assign) NSUInteger index;
- (void)displayTiledImageNamed:(CGPDFPageRef)page size:(CGSize)imageSize;
@end
@interface ISVportrate : ImageScrollView {}
@end
@interface ISVLandscape : ImageScrollView {}
@end
@implementation ISVportrate : ImageScrollView
// error: property 'index' attempting to use ivar 'index' declared in
// super class of 'ISVportrate'
@synthesize index;
// ... my methods ...
@end
@implementation ISVLandscape : ImageScrollView
// error: property 'index' attempting to use ivar 'index' declared in
// super class of 'ISVLandscape'
@synthesize index;
// ... my methods ...
@end
我不这样做的权利,我是谁?见上面我有4个错误......这是我第一次上课......帮助我理解,我想我已经差不多了。
@synthesize
进入ImageScrollView
的@implementation
,而不是在子类中。
self.ISVportrate
没有意义(除非你有一个方法叫做-ISVportrate
,这也没有任何意义)。
这听起来像你还没有完全熟悉面向对象的编程。你会想创建一个你的子类的适当的实例,并将其作为任何视图的子视图包含它......
好吧,我开始喝伏特加,所以我现在不太确定你说什么,如果你可以详细阐述一下,我会看清楚它,我相信我会得到它。我现在正在逐步学习。 – user422241 2010-08-23 02:39:55
所以你说@synthesize进入了ImageScrollView的@implementation ...这是否意味着我应该保持ImageScrollView的实现并在ImageScrollView中为ISVportrate和ISVlandscape重复什么?因为现在我没有执行力度只有接口只图像滚动视图: @implementation ISVportrate:ImageScrollView & @implementation ISVlandscape:ImageScrollView 不是:@implementation ImageScrollView。 我不确定关于NSInteger索引...在哪里必须申报等... 谢谢队友! – user422241 2010-08-23 02:40:19
请阅读并重新阅读:http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html您需要了解面向对象编程的基础知识才能取得成功。 (真的 - 这是最好的前进方向。) – bbum 2010-08-23 05:39:11
这是什么编程语言?将来,请至少在标签中提及编程语言,但最好也在问题本身中提及。 – Timwi 2010-08-23 00:14:32
对我来说看起来像Objective-C。 – 2010-08-23 00:21:30
iphone sdk xcode objc大声笑抱歉maaaaate! :P – user422241 2010-08-23 00:29:51