访问子类中的主类变量值

时间:2012-08-29 11:15:54

标签: objective-c macos

我有mainClasssubClass

mainClass.h:

@interface mainClass : NSOpenGLView {
   NSBitmapImageRep *repG;
 }
@property (nonatomic, retain) NSBitmapImageRep *repG;
@end

mainClas.m:

#import "mainClass.h"

@implementation mainClass
@synthesize repG;
.....

-(void)setBitmapRepresentation {
   repG = [[NSBitmapImageRep alloc] initWithCIImage:someMyImage];
}
@end

subClass.h

#import "mainClass.h"

@interface subClass : mainClass {
   CIImage *someInputImage;
   CIFilter *myFilter;
}
@end

subClass.m

#import subClass.h

@implementation filteringFrontLayer

.......

-(void)setInputImageForFilter {
    someInputImage = [[CIImage alloc] initWithBitmapImageRep:repG];
    [myFilter setValue:someInputImage forKey:@"inputImage"];
}

它不起作用。它返回空CIImage(Invalid parameter not satisfying: ciImage != nil)。如何在我的子类中使用其值(在mainClass中设置值)访问repG(位图数据)?

1 个答案:

答案 0 :(得分:0)

您还可以使用其访问者访问该媒体:

someInputImage = [[CIImage alloc] initWithBitmapImageRep:[self repG]];