Re: Java/Cocoa-Java Delay
Re: Java/Cocoa-Java Delay
- Subject: Re: Java/Cocoa-Java Delay
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 25 May 2001 01:31:18 -0700
On Thursday, May 24, 2001, at 11:31 PM, William Jamieson wrote:
Hi All,
Here's a quick one for y'all.
How do I do a delay in Java or Cocoa-Java??? Here's the gist of what
I'm
trying to do:
Loop while myVariable = false
delay for 2 seconds
End loop
Anyone got any flashes of brilliance and/or inspiration?????
Rather than wait for two seconds (burning up CPU time), why not just
send yourself a message in two seconds with an NSTimer?
NSTimer *twoSecondTimer = [[NSTimer timerWithTimeInterval:2.0
target:self
selector:@selector(whateverYouShouldDo)
userInfo:nil
repeats:NO] retain];
and down in your -whateverYouShouldDo method, you should -release the
timer.
-jcr
"These kids today don't know the simple joy of saving four bytes of
page-0 memory on a 6502" - unknown