Re: Running a daemon
Re: Running a daemon
- Subject: Re: Running a daemon
- From: Ivan C Myrvold <email@hidden>
- Date: Wed, 18 Jun 2008 15:34:20 +0200
Den 18. juni. 2008 kl. 14:22 skrev email@hidden:
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 (email@hidden)
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:
This email sent to email@hidden