Re: Foundation Tool & NSApplicationMain?
Re: Foundation Tool & NSApplicationMain?
- Subject: Re: Foundation Tool & NSApplicationMain?
- From: Sherm Pendley <email@hidden>
- Date: Mon, 21 Nov 2005 22:00:12 -0500
On Nov 21, 2005, at 7:04 PM, George Lawrence Storm wrote:
I am in the process of converting a traditional Cocoa application
into a UNIX command line tool.
The project started life as a "Cocoa Application". Currently I am
working within XCode (2.2). The tool is working fine within the
IDE, but not under the Terminal.
If I attempt to start as a new "Foundation Tool" I cannot see
anyway to get it to function with NSApplicationMain, as the project
"Target" has no properties tab to allow me to set a principle class
or nib file (needed to use NSApplicationMain).
A command-line tool has no principal class, no nib files, no GUI, no
event loop, no shared NSApplication instance, etc., so
NSApplicationMain() is pointless in that context; few (if any) of the
things it does are applicable.
A Foundation tool begins in main(), just like any other ordinary C
program. If you need an event loop, a responder chain, etc., you'll
need to create them. (A subset of AppKit that was built atop Curses
would be quite interesting, but as far as I'm aware, no such thing
actually exists...)
On the other hand leaving it as a Cocoa application it is not being
recognized by the "Terminal" application despite being moved to /
bin. (works fine in the IDE)
Don't put things in /bin - that and /usr/bin belong to Apple. /usr/
local/bin is better.
My question is how do I get a Cocoa application to work as a
"Foundation Tool", or get a Foundation tool to work using
NSApplicationMain.
Keep in mind that you're talking about two fundamentally different
things here. A Cocoa app has a GUI, and is packaged along with all
its resources in a .app bundle. A Foundation Tool has no GUI, and
it's just a standalone executable file with no bundled nibs or other
resources.
So essentially the answer to your question is, remove all of the
controller- and view-related classes from your Cocoa app. Then, parse
the command-line switches in main(), and call methods in your model
classes as needed to hand them.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden