0

my project is some kind of a timing application for Mac OS X and I want to cause drawRect in TimeCircle to refresh myView. I´m aware that I asked a similar question before. But my problem is not solved yet and it is different from other topics which are similar.

What I have so far:

  1. An NSObject Class TimeController which starts a timer and modifies some NSTextEdits on a per second base.

  2. An NSView Class TimeCircle which is connected to a custom view which I want to draw a circle with a clock like hand representing the progress.

  3. Imported TimeCircle.h in TimeController.m

  4. An instance method drawRectOutsideWrapper which I send a message when the timer is running. [TimeCircle drawRectOutsideWrapper:(float) seconds]; this works.

drawRectOutsideWrapper is this:

- (void) drawRectOutsideWrapper:(float) seconds {
   liveAngle= seconds;
   [self->myTimeCircleView setNeedsDisplay:YES];
}

drawRectOutsideWrapper receives the message from TimeController correctly!

The problem is that [self->myTimeCircleView setNeedsDisplay:YES]; doesn´t fire drawRect. It just does nothing. For testing purposes I integrated a slider makeLiveLine which actually does the same thing and drawRect gets triggered correctly:

- (IBAction)makeLiveLine:(id)sender {
   liveAngle= [sender intValue];
   [self->myTimeCircleView setNeedsDisplay:YES];
}

Any clues why one is doing the job and one doesn't?

Ronald Hofmann
  • 1,390
  • 2
  • 15
  • 26
  • I am not sure. Can you try to call IBAction method from drawRectOutsideWrapper(). Might be some problem of threads, if call this using selector in different thread. – Anoop Vaidya Nov 20 '12 at 08:10
  • mmh, I sent a message to - (IBAction)makeLiveLine:(id)sender and it does setNeedsDisplay:YES but without success. drawRect is still not triggered. This is annoying. It is perfect when using my slider. – Ronald Hofmann Nov 20 '12 at 15:57

0 Answers0