Most likely the method signature for drawView
is incorrect. From the NSTimer class reference:
The message to send to target when the
timer fires. The selector must have
the following signature:
- (void)timerFireMethod:(NSTimer*)theTimer
So, your drawView
method should look like this:
- (void)drawView:(NSTimer*)theTimer
{
// Draw the view
}
Also, correct your code to be this (notice the colon following "drawView"):
animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval) target:self.delegate selector:@selector(drawView:) userInfo:nil repeats:TRUE];
On a side note, I'm not sure what your drawView
is responsible for (I would assume drawing a view). However, there are built-in mechanisms for drawing, which should be followed (except for rare circumstances). Usually, if you have an NSView, you call setNeedsDisplay
, which will cause the UI to tell your NSView to redraw itself by calling your NSView's drawRect:
. I only mention this since you said you were new to Objective-C, so you might not be aware of this, and end up writing more code than you need to. If you follow this design, you could have your timer call setNeedsDisplay
periodically.