Hey guys - thanks for the tips.
I must be really thick as I couldn't get it to work but... I managed to
work something out by just creating a new thread for the loop - and it seems to
be working ok *grin*
Thanks again for your help!
Aston
On 25 May 2011, at 21:28, Laurent Sansonetti wrot
Just one minor detail, the NSTimer callback method accepts an argument (which
is a reference to the NSTimer object). So it should be:
def drawWord(sender)
…
end
If it works otherwise, then it's pure luck :)
Laurent
On May 24, 2011, at 10:50 PM, Thomas R. Koll wrote:
> Laurent is righ
Just as an extra FYI, you are indeed blocking the main thread by using
`sleep 1`, which is a synchronous call and thus in that one second no
other code on the same thread will have a chance to update your views.
On Wed, May 25, 2011 at 7:50 AM, Thomas R. Koll wrote:
> Laurent is right and and I t
Laurent is right and and I think best would be for you to use a NSTimer.
def drawWord
if !next_word
self.timer.invalidate
return
end
self.label.stringValue = next_word
self.setNeedsDisplay true
end
def next_word
...
end
self.timer = NSTimer.scheduledTimerWithTimeInterval( 1/20.
Hi,
It doesn't work because you're (probably) blocking the main thread,
which is responsible for drawing. What you want to do instead is
scheduling a timer inside the main run loop. Look at the NSTimer
class. Also, don't forget to force the view to be redrawn, by using
the setNeedsDisplay: method.
I have a label that I have set to blank, and after a user clicks 'go' I
generate a random word or number and use:
self.label.stringValue = "some_word"
to update the view.
However, I would like to show 200 or so random words in quick succession before
the final one is shown - just because it's