In fact, I read the following document:
I don't quite understand it, anyone knows how to do?
and also, what does this mean:
is there any example about how to use LSRegisterURL and SMLoginItemSetEnabled?
+ (void)startHelper {
NSURL *helperURL = [[[NSBundle mainBundle] bundleURL] URLByAppendingPathComponent:@"Contents/Library/LoginItems/YourHelper.app" isDirectory:YES];
OSStatus status = LSRegisterURL((CFURLRef)helperURL, YES);
if (status != noErr) {
NSLog(@"Failed to LSRegisterURL '%@': %jd", helperURL, (intmax_t)status);
}
Boolean success = SMLoginItemSetEnabled(CFSTR("com.yourcompany.helper-CFBundleIdentifier-here"), YES);
if (!success) {
NSLog(@"Failed to start Helper");
}
}
Note that the Helper must be packaged with the main app in the "Contents/Library/LoginItems" directory. You will need to create it during the build and copy the helper there.