Re: Launchd daemon
Re: Launchd daemon
- Subject: Re: Launchd daemon
- From: Steve Sisak <email@hidden>
- Date: Mon, 18 Mar 2013 13:20:19 -0400
Title: Re: Launchd daemon
At 10:05 AM -0700 3/18/13, Jens Alfke wrote:
On Mar 18, 2013, at 8:36 AM, Erwin Namal
<email@hidden>
wrote:
- How to set up my project to use
Objective-C for my daemon.
Just create a new project and choose the
"Command-Line Tool" template. Then add .m files to
it.
- What does my Objective-C entry point
look like (int main() ?)
Yeah, a main() function.
Just be aware that any place
you've got a C-level callback that runs Obj-C code, wrap its body with
@autorelease{} to make sure objects autoreleased inside it get
cleaned up. Same thing applies to setup code you run before dropping
into the kqueue loop.
To expand on what Jens said, Xcode has a "Foundation Tool"
template which is exactly equal to an Objective-C command line
tool.
The main() it creates for you is:
#import
<Foundation/Foundation.h>
int main
(int
argc, const char * argv[]) {
NSAutoreleasePool * pool =
[[NSAutoreleasePool alloc] init];
// insert code
here...
NSLog(@"Hello,
World!");
[pool
drain];
return 0;
}
You'll also want to link against Foundation.framework to get the
Obj-C runtime and that's about it. You can also use @autorelease if
you prefer -- or ARC.
HTH,
-Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden