Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrFusion

macrumors 6502a
Original poster
Jun 8, 2005
613
0
West-Europe
With "Application is background only" in the .plist of your app, it is possible to specify that an app is background only. Apple calls this an "agent". This can be combined with an icon on the right side in the statusbar (apple bar/menubar) via nsstatusitem.

I want to make an app that runs continuously in the background. When the user starts (via a menu on the statusitem) the GUI app, it should look and act like a regular app with dock icon and menubar. The background app should also continue running at the same time. This is probably possible by just making two different apps. It is not a document-based app, but it is a core-data app. So the data and the datafile is (should? will? can't?) identical for both apps.

What would be the best approach to tackle this? Two separate apps (but how would you deal with the datafile issue) or 1 app where the .plist is changed on the fly (or is that not possible?). As always, thank you for your time and answer!
 
So you are really asking for a daemon to run in the background and the gui justs hooks into it? What are you doing that requires it to run in the background?
 
So you are really asking for a daemon to run in the background and the gui justs hooks into it? What are you doing that requires it to run in the background?

My program should check with other computers on a regular basis, retrieve and store information and when necessary (depending on the data) report back to the user for further intervention. It should act as independently as possible and bother the user as little as possible. Maybe once a week, a few times tops, the user will have to do something. But it is important not to delay that intervention too much. That would just waste time. Messages will be displayed via growl. On the hand, if the user wants to check the status, (s)he should be able to start the gui itself via the statusbar icon.
 
I would probably have the background app handle interacting with the file, and the foreground app communicate with the background app.
 
I would probably have the background app handle interacting with the file, and the foreground app communicate with the background app.

I can try that. Syncing the two datafiles (one per app) is maybe also an option? I just started reading about that, not sure yet how straightforward that is.
 
While convenient, I would not recommend NSDistributedNotificationCenter for that purpose. For example, it makes no guarantees that it won't drop notifications when heavily loaded.

Cocoa distributed objects or standard unix IPC methods are better choices.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.