Hello guys, im new to programming and am creating an app which has 2 components an agent component which is always running in the background and a UI component which the user like any app can open and close it when they need it. Even if the app has been quit the agent continues to be run. for the sake of simplicity lets say the UI simply displays the data collected by the agent, and the agent updates its data every 5 seconds(data is stored in a dictionary, in the agents code), how will i update the UI to reflect the changes? also how will i get the values in the dictionary from my agent? i was thinking of either using xpc or writing to a file. I think i prefer XPC because its more efficient right?
Well, as with most engineering questions, the answer begins with "it depends". It depends what the data is, and what a user is going to do with it. Generally, you shouldn't hit the file system if you don't need to.
What you're building (an agent with a separate UI process) is quite advanced for someone new to programming. You asked, "how would I update the UI to reflect the changes"? If you're new enough to programming to have to ask this question, you should probably start with a simple, single-process application. Once you know how to make a UI respond to changes in your data model, you can work on pushing those changes from another process.