0

I have mainClass and subClass.

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"];
}

And it doesn't works. It returns empty CIImage (Invalid parameter not satisfying: ciImage != nil). How can I access repG (bitmap data) with its value (value is set in mainClass) in my subClass?

pasawaya
  • 11,515
  • 7
  • 53
  • 92
hockeyman
  • 1,141
  • 6
  • 27
  • 57

1 Answers1

0

You can also access the property with its accessor:

someInputImage = [[CIImage alloc] initWithBitmapImageRep:[self repG]];
Resh32
  • 6,500
  • 3
  • 32
  • 40
  • It still returns empty `repG`. I added `NSLog(@"repG.Height:%ld, repG.Width:%ld", [self repG].pixelsHigh, [self repG].pixelsWide);` and it returns `repG.Height:0, repG.Width:0` – hockeyman Aug 29 '12 at 11:50
  • Could you please put the same logs inside setBitmapRepresentation. I'd like to make sure that they are set initially. – Resh32 Aug 29 '12 at 15:01
  • What do you mean with `setBitmapRepresentation`? By the way, same `NSLog` returns `repG.Height:2000, repG.Width:3200` in main class at the same time – hockeyman Aug 30 '12 at 05:37
  • Do you have multiple instances of subClass running at the same time? Maybe you are seeing logs of different instances ? – Resh32 Aug 30 '12 at 07:02
  • No. All the time my main class is running. The one and only subclass runs only when user selection changes – hockeyman Aug 30 '12 at 08:53
  • So if I understand correctly, you have two objects running, one is an instance of the mainClass, the other one is an instance of subClass, is that right? In that case, the subclass instance would of course not have the same value for repG. – Resh32 Aug 30 '12 at 08:56
  • Yes. Is it possible to make it having same value for repG? – hockeyman Aug 30 '12 at 08:58
  • 1
    You could look at http://stackoverflow.com/questions/1063229/objective-c-static-class-level-variables or create a singleton to share that variable. – Resh32 Aug 30 '12 at 09:21