BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

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!


Save 50% in my Black Friday sale.

SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

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

Reply to this topic…

You need to create an account or log in to reply.

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.