From: Jonathan P. <jp...@dc...> - 2005-11-26 13:47:03
|
On 26 Nov 2005, at 5:40, Neil Stevens wrote: > > def endCheck > @resultsSpinner.stopAnimation_ > @textField.setEnabled(true) > @button.setTitle('Validate') > end > > The app crashes for me on the stopAnimation_ call, but doesn't crash > when I omit that call. You may need stopAnimation(nil), which is a method on NSProgressIndicator, whereas stopAnimation_ is defined on NSAnimation. That might fix it. > So am I doing this wrong here? I'm learning Cocoa as I go here, never > having used it before trying Ruby Cocoa. What would be the right > way to > call back to the main thread? Sorry, I should have been clearer in my original post. self.performSelector doesn't help any here - it just ends up calling back on the same thread. There are some other performSelector... methods that are of use, in particular performSelectorOnMainThread_withObject_waitUntilDone. This schedules a call during a pass on the main thread runloop. It's important to always give 'waitUntilDone' as false here, because otherwise it degenerates into a direct call like performSelector. I need to have more of a think about the thread safety here, but it's possible that everything will work out if you fix stopAnimation(nil) - without needing to do the performSelector... stuff at all. Let me know how you get on. Thanks Jonathan |