TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

XPC – can I pass useful data with it?

Forums > macOS

I have been doing some testing with setting up XPC as a LaunchAgent and finally had enough time to get my head wrapped around it enough for getting a minimal server / client set up going based on some tutorials.

But now I want to pass my own data and it seems limited to some very boring data types.

Any idea on how to pass a BigInt struct?

Specifically this one --

I have a huge data set (pre-computed) that I would like to store ALL in memory VS on disk. I currently have a 'load to memory' on first pull style cache (so computation speeds up the longer program runs / more are in memory, but I would like that speed immediately).

  • David


What XPC tutorials do you recommend?

Have you seen the Apple reference on XPC Objects?

One of the XPC object types is an array whose elements are XPC object types such as integers. BigInt has methods to convert to and from a byte array, i.e., an array of UInt8 elements.


@bobstern -- I found these two articles to be straighforward and easy enough to follow / replicate / adapt:

command line

app / GUI

yes, I saw the support for some familar element types. I may look into serving in XPC via Data/Bytes (that is the format I am storing the BigInt's to disk)... but that would require a conversion to the BigInt type every time I access a value via ByteArray (even if I have already converted it 20 times prior). I would rather never do any computional 'work' that was identical more that once.

I may, as an alternative, just convert my whole app into something like a service. Currently it is just a run once command line app.

I can probably just have whole app load at start and expose it occasionaly via a GUI, command line, or services contentual menu.

Thanks, in any case... I think it might be a good time to brush up on SwiftUI and general GUI app lifecycle. I had been doing some iOS development in 2007-2009, having studied Objective-C since the MacOsX Developer Preview way back in the early 2000's.

Swift I have been picking up the last year and a half in my spare time, but have been command line focused.


Thanks, @serinx!


Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.