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

mehdies

macrumors member
Original poster
Jun 10, 2012
41
0
hi guys

I want to write program that work like daemon and do something in every second for example.and startup in system boot.could you help me?

my program overview :

Code:
#import <Cocoa/Cocoa.h>

func1()
{ 
.....
}

func2()
{
....
}

func3()
{
....
}

int main()
{
func1();
func2();
func3(); /// This function must be execute interval - every second for example
}

I don't know must be use launctl with .plist file?
Thanks
 
Last edited:
It seems like youre asking for for a launchctl script that runs a specific function inside if your program. I think that you will find this is not possible.

What you should instead do, is move everything that would be considered 'setup' into a single place and wrap it in a check that determines if it needs setup. Usually the existence of a file, or a key-value pair in a plist for example.

Thus you can run the program on an interval and it will just skip the functions that don't need to be run.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.