UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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 -- https://github.com/leif-ibsen/BigInt

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

3      

What XPC tutorials do you recommend?

Have you seen the Apple reference on XPC Objects? https://developer.apple.com/documentation/xpc/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.

3      

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

command line https://rderik.com/blog/creating-a-launch-agent-that-provides-an-xpc-service-on-macos/

app / GUI https://rderik.com/blog/xpc-services-on-macos-apps-using-swift/

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.

4      

Thanks, @serinx!

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.