Re: NSStatusItem, RunLoops and daemons (Oh My)
Re: NSStatusItem, RunLoops and daemons (Oh My)
- Subject: Re: NSStatusItem, RunLoops and daemons (Oh My)
- From: Dave Camp <email@hidden>
- Date: Wed, 12 May 2004 14:36:43 -0700
On May 12, 2004, at 1:49 PM, Michael Cashwell wrote:
Where I'm hung up is the language to use for the daemon (BSD C or
Obj-C) because of the need for IPC between them and the apparent
prohibition against using some system frameworks (AppKit) within a
daemon. What I have so far is:
Sys Pref Panel Obj-C / Cocoa
Status Obj-C / Cocoa
daemon ???
I have a rudimentary CLI app that I'm trying to morph into the daemon.
But I'm stuck on the IPC with the other parts. According to the best
docs I can find
(http://developer.apple.com/documentation/UserExperience/Conceptual/
PreferencePanes/index.html) I could use distributed objects if I wrote
the daemon in Obj-C / Cocoa. But that would be a rewrite from what I
have now and I haven't been able to find any real CLI examples written
this way. One-liners that CFShow a "Hello World" message or that don't
show me how to handle argc / argv the cocoa way are of little help.
As far as I know, you can use Obj-C and the Foundation framework from a
daemon. You just can't use AppKit since it primarily deals with UI and
obviously a boot daemon cannot have any UI.
I could just stick with BSD C for the daemon but then I can't use
distributed objects. That same html page says that I could use
Distributed Notifications and goes on to show some code snippets, but
no working example. And elsewhere on that page it says that for the
notifications to work I must enter a Runloop. I also expect to need
the RunLoop in order to register for changes in the Sys Config
(Location) but I haven't really gotten that far.
You will need to choose a IPC method that works well across the
different bootstrap servers your processes are on (if I got my
terminology correct). Search the archives (Carbon and Cocoa lists,
maybe the networking list too) on that.
The problem is, I cannot figure out how to create a run loop in a BSD
(non-Obj-C, non-carbon) app. Again, it would seem to me that template
/ sample code claiming to be a daemon or tool written in Obj-C / Cocoa
might show how to deal with the run loop.
I think RunLoops are easier than you think. Each pthread in the system
has a RunLoop associated with it (you don't do anything to cause this
to happen). CFRunLoopGetCurrent or [NSRunLoop currentRunLoop] will
return the correct RunLoop reference for the current thread.
While I admit I'm green on Obj-C/Cocoa, I do see the advantages for
processes with any substantial UI. But I'm less sure about using it
for a faceless daemon given the dearth of real example code showing
how to do it right. But with the features I need I don't want to be
closed minded.
I think it's a matter of preference. If you are more comfortable with
one language, or one set of frameworks has a significant advantage,
then go with that. Also, don't forget that you can mix C, C++ and Obj-C
in the same app. Same goes for CoreFoundation and Foundation
frameworks. You are not locked into one method of development in your
app.
Dave
---
It is dark; you are likely to be eaten by a grue. -Zork
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.