> Hi,
>
[quoted text clipped - 7 lines]
> main.m? (I'm running it in a new NSThread, if that makes any
> difference.)
If you're calling NSApplicationMain(), then
-applicationDidFinishLaunching is probably a good place to put your
startup code.

Signature
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 2.0: Delocalize, Repair Permissions, lots more.
See http://www.atomicbird.com/
Tom - 20 Jun 2006 20:21 GMT
> ...
> > I assume there's an application start event I can connect to my code,
[quoted text clipped - 5 lines]
> -applicationDidFinishLaunching is probably a good place to put your
> startup code.
That's in a delegate connected to the main app object, right? (I've
just been googling some more.)
I should probably read the O'Reilly book or something..
cheers!
Tom
> Hi,
>
[quoted text clipped - 7 lines]
> main.m? (I'm running it in a new NSThread, if that makes any
> difference.)
In article <tph-BE40DA.13032520062006@localhost>, Tom Harrington
answered that question.
I have a tiny bit to add: you will probably want to split the 'local web
server' part out of the 'may eventually have a preferences window' part.
Depending on what your app is supposed to do, solutions may be:
- two applications, one of which is faceless
- a control panel for the preferences and an application
> I also want to respond to Dock icon clicks by opening a URL in the
> default web browser. Any help with this would also be much appreciated!
I believe detecting the click is done by trapping a reopen event in your
application delegate:
(BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication
hasVisibleWindows:(BOOL)flag
There may not be a reliable way to discriminate this from a double-click
of an already-opened application.
Launching a URL is described in
<http://developer.apple.com/documentation/Carbon/Conceptual/LaunchService
sConcepts/LSCTasks/chapter_3_section_2.html>
[the easier to find <http://developer.apple.com/qa/nw/nw60.html> is a
red herring. That example is 'a bit' old (literally from last century)]
Reinder
Tom - 21 Jun 2006 09:07 GMT
>... I believe detecting the click is done by trapping a reopen event in your
> application delegate:
[quoted text clipped - 6 lines]
>
> Launching a URL is described in ...
Cool! Everything's working now! Thanks, Reinder.
Tom
Simon Slavin - 22 Jun 2006 22:14 GMT
> I have a tiny bit to add: you will probably want to split the 'local web
> server' part out of the 'may eventually have a preferences window' part.
>
> Depending on what your app is supposed to do, solutions may be:
> - two applications, one of which is faceless
> - a control panel for the preferences and an application
Yes yes yes. Definitely don't try to add a window to a server
application. Your users might want to run the application when nobody is
logged-into the computer.
A control panel is one way to do it. A simple application is another.
For bonus points, instead of writing either of those, write an application
which can actually be run on a different computer -- e.g. the one on administrator's desk -- instead of the computer that the server is running on. Since you write that you're actually writing a local web server, you might find it easy to do this by adding a web interface.
The client/server design, whereby nobody is expected to type on the computer that runs the server, is an excellent piece of design which leads to added convenience for administrators and greater security for the server computer (where security is incredibly important).
Simon.

Signature
http://www.hearsay.demon.co.uk