Den 18. juni. 2008 kl. 14:22 skrev [EMAIL PROTECTED]:

Ivan C Myrvold wrote on 2008-06-18 13:07:50:

I have developed a daemon that have an Objective-C class
"ApplicationWatcher" which checks the foreground applications with
NSWorkspace.

In my main I create the ApplicationWatcher, and the class starts an
NSTimer.
This is probably a stupid question, but I want the daemon to continue
running, but at the end of main the daemon quit, even if I have an
NSTimer running.
So what should I do in main to have the daemon running?

In an ordinary Cocoa application the main contains "return
NSApplicationMain(argc, (const char **) argv);", but as this is a
daemon I can't call this.


The bit of NSApplicationMain() which you need to replicate is the run
loop. Timers get scheduled in run loops.  Have a look at the NSRunLoop
documentation (you probably want [[NSRunLoop currentRunLoop] run]).

Cheers,
Graham.

That worked perfectly. Thanks!

Ivan





--
Graham Lee
Senior Macintosh Software Engineer, Sophos

Tel: 01235 540266 (Direct)
Web: http://www.sophos.com
Sophos - Security and Control

Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon,
OX14 3YP, United Kingdom.

Company Reg No 2096520. VAT Reg No GB 348 3873 20.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to