haven't used rubycocoa, but I'll try...;-)

On Apr 4, 2009, at 12:55 PM, abc wrote:

> 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

that looks ok
>
> app.setDelegate(AppDelegate.alloc.init)

this doesn't look right; you'd typically want one of your classes to  
act as the NSApplicationDelegate object. Is AppDelegate one of your  
classes?
>
> 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

I wouldn't think you'd have to alloc and init the NSAuto... class,  
typically any object you'd want auto released you could just call  
autorelease on, and you're not making any other calls involving the  
pool var before you release it at the end of your method def, so why  
is it there?
>
>    app = NSApplication.sharedApplication
>    app.setDelegate(AppDelegate.alloc.init)
>    app.run
>    pool.release
>  end
> end
>
> runner = AppRunner.alloc.init
> NSThread.detachNewThreadSelector_toTarget_withObject(:run, runner,
> nil)
>
No idea here, but is it necessary to run the app in a separate thread?



























> 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.
>