Thank you for the prompt response! I have some more questions if you don't mind.
The agent is instantiated for each relevant session — remember that you can have multiple GUI login sessions running simultaneously — and each instance connects to the daemon via an IPC mechanism of your choice (although I generally recommend XPC) and do work on behalf of the daemon in each GUI context.
Does this mean that in general my application should be done in two parts, and xpc service that deals with the networking, that can run without interruption in any session (login and logged in user), and then my NSApplication to deal with the very little UI I need and to capture user screen and other input?
The standard pattern is have a launchd daemon that manages the network connection and then have a launchd agent that’s set up to both pre-login (LoginWindow) and GUI login (Aqua) sessions.
As I mentioned before, it is a remote control application I'm working on and this is how I understand the standard patter would work.
my daemon:
It would be launched and kept alive through any session (LoginWindow and when user is logged in)
it would be in charge of my networking code, connecting to my client and receiving input from the client
may agent
one for LoginWindow and one when the user is launched.
takes care of the NSMenu my application represent
it captures all the screen, user input and sends it to my daemon which will then send it to the client.
Right now my application works and it is all contained within the same project, but it sounds like it would be better to split it and have a xpc service and a agent? this way The XPC Service can run and maintain connection with the client "non stop"?