A
abc
Hi all,
I'm trying to build a simple Cocoa app using RubyCocoa.
I've no experience with Cocoa, but I'm not trying to make anything
fancy. In short, I'd like to create a window that acts as an observer
for my terminal app. It'll give feedback to the user with a progress
bar and a few more things.
Now the problem is that app.run never returns:
app = NSApplication.sharedApplication
app.setDelegate(AppDelegate.alloc.init)
app.run
I now I cannot use Ruby threads within RubyCocoa code, and I'm stuck
using Cocoa worker threads. I've done this, but it doesn't work:
class AppRunner < NSObject
def run
pool = NSAutoreleasePool.alloc.init
app = NSApplication.sharedApplication
app.setDelegate(AppDelegate.alloc.init)
app.run
pool.release
end
end
runner = AppRunner.alloc.init
NSThread.detachNewThreadSelector_toTarget_withObjectrun, runner,
nil)
It runs but the app doesn't pop up. I suspect it is due to the usage
of a worker thread. But my knowledge of Cocoa is non-existent.
Any ideas?
I know MacRuby could be an option, but my project is not 1.9
compatible due to some gem dependencies.
Thanks in advance.
I'm trying to build a simple Cocoa app using RubyCocoa.
I've no experience with Cocoa, but I'm not trying to make anything
fancy. In short, I'd like to create a window that acts as an observer
for my terminal app. It'll give feedback to the user with a progress
bar and a few more things.
Now the problem is that app.run never returns:
app = NSApplication.sharedApplication
app.setDelegate(AppDelegate.alloc.init)
app.run
I now I cannot use Ruby threads within RubyCocoa code, and I'm stuck
using Cocoa worker threads. I've done this, but it doesn't work:
class AppRunner < NSObject
def run
pool = NSAutoreleasePool.alloc.init
app = NSApplication.sharedApplication
app.setDelegate(AppDelegate.alloc.init)
app.run
pool.release
end
end
runner = AppRunner.alloc.init
NSThread.detachNewThreadSelector_toTarget_withObjectrun, runner,
nil)
It runs but the app doesn't pop up. I suspect it is due to the usage
of a worker thread. But my knowledge of Cocoa is non-existent.
Any ideas?
I know MacRuby could be an option, but my project is not 1.9
compatible due to some gem dependencies.
Thanks in advance.