0

He, since I use my images as instance variables (cause I need to draw them all very often) in this way (in my NSView):

@implementation BeatView
- (id)initWithFrame:(NSRect)frame{
self = [super initWithFrame:frame];
if (self) {
    bpm=160;
    mbpm=0;
    NSImage *bz_BG = [NSImage imageNamed:@"mw_bg01.png"];
    NSImage *bz_PaAc = [NSImage imageNamed:@"pattactive.png"];
    NSImage *bz_PaIa = [NSImage imageNamed:@"pattinactive.png"];
}
return self;
}

and then drawn:

- (void)drawRect:(NSRect)dirtyRect{
     NSPoint imagePos = NSMakePoint(0, 0);
    [bz_BG dissolveToPoint:imagePos fraction:1.0];
}

there are no errors (only warnings that the image variables are not used). When running, no image will be drawn. What am I doing wrong here? Thanks...

fw2601
  • 83
  • 6

2 Answers2

2

You are not initialising your instance variables. You are creating new variables during init method, hence the warning.

Change your code to the following

_bz_BG = [NSImage imageNamed:@"mw_bg01.png"];
_bz_PaAc = [NSImage imageNamed:@"pattactive.png"];
_bz_PaIa = [NSImage imageNamed:@"pattinactive.png"];

And in your header file, declare those variables as

@property (nonatomic, retain) NSImage *bz_BG;
@property (nonatomic, retain) NSImage *bz_PaAc;
@property (nonatomic, retain) NSImage *bz_PaIa;

By default XCode (in version 4 and later I believe) synthesises your properties with an underscore in the beginning (equivalent to putting @synthesize bz_BG = _bz_BG; at the beginning of your implementation file). Hence change your references to _bz_BG instead

Ege Akpinar
  • 3,266
  • 1
  • 23
  • 29
0

What about using the method drawToPoint: instead of dissolveToPoint?

CainaSouza
  • 1,417
  • 2
  • 16
  • 31