|
From: Jonathan P. <jp...@dc...> - 2005-06-06 21:43:55
|
>
>
> the rb_main.rb file contains
>
> if $0 == __FILE__ then
> rb_main_init
> OSX.NSApplicationMain(0, nil)
> end
>
> if it instead had
>
> if $0 == __FILE__ then
> rb_main_init
> app = OSX.NSApplicationMain(0, nil)
> end
>
> would that work? I tried that, but it appears that "app" was too
> local, and vanished before I could access it. But it's quite
> possible I just don't have a good enough grasp of variable scope to
> have figured out how to set that up correctly.
That won't work. NSApplicationMain doesn't return until the
application exits - it handles running the main event loop of the
application.
If you look at the documentation for the NSApplicationMain function,
you'll see that it returns an int (not an NSApplication*):
NSApplicationMain
Called by the main function to create and run the application.
int NSApplicationMain(int argc, const char *argv[])
> "sharedApplication only performs the initialization once; if you
> invoke it more than once, it simply returns the NSApplication
> object it created previously."
This is a common idiom in Cocoa. There are lots of class-level
sharedBlah methods that return a singleton.
|