Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rerelease

macrumors regular
Original poster
Jun 8, 2009
218
0
eesti
I'm trying to build my first graphical app that utilizes NSRects and NSPoints to draw a very basic clock into a custom MyView.

Thus far the result looks like this:
bja1jb.png


However, the clock is static and as such not very impressive. How could I make my custom NSView object call the -drawRect method repeatedly (every once a second)? Is there any easy way to do it?

Keep in mind that I have very little idea of what I'm doing and the code is really basic so baby steps would be useful. :)

Thanks for your help!
 
You can use NSTimer. In your custom view somewhere, create it like so:

Code:
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(redraw) userInfo:nil repeats:YES];

Then setup the timer's action method to redraw the view:

Code:
- (void)redraw
{
    [self setNeedsDisplay:YES];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.