views:

83

answers:

2

I need to launch a program that will at a users pre defined interval, open and bring to front a (preferrably very good looking) style window to ask the user to fill in some details. I have written some normal cocoa apps, but this seems to require some extra knowledge I dont have (: Where do I start?

(And before anyone gets upset i might want to bug people, the purpose of the application is to create an OS/X version of something we have at work that allows a user to request that they get reminded to fill out their timecard/report at/on a user configurable time period)

The closest thing I can imagine it being like is growl.

+2  A: 

Assuming you can target 10.5 and later, launchd would let you easily launch your application periodically. Then you could make the application that gets user information as normal, without worrying about keeping it running yourself.

If you are targeting 10.4 though, don't use launchd for this, as launch agents were very broken until 10.5.

smorgan
+2  A: 

You have a few options. Like smorgan said, launchd works very well for this. Your other (relatively easy) option would be to add your application to the user's Login Items list. Take a look at this StackOverflow question for details on how to do that. I have actually used this in an application to install a small helper, and it works very well. Then, your application would use something like an NSTimer (or some other kind of notification, as appropriate to your application) to determine when to show the window.

If you want your program to be hidden except when the window is visible, you could also consider making it an LSUIElement. Basically, you add the LSUIElement key to your Info.plist file, and when you run the program, it will have no menu bar and no dock icon. The user will only see a UI when you actually show your window.

If you combine these two, you have an app that launches when the user logs in (you can also launch it manually, if needed) and only shows a window when you want it to.

Alex