My question is: Is this pattern—creating a new, temporary ModelContext inside each of these entities(for:) functions (and presumably inside all the other required query/data-import functions for all of my entity types)—the correct way to bridge the gap between the UUID requirement from AppEntity and my PersistentIdentifier-based actor? Yes. ModelContext.init(_ container: ModelContainer) returns a nonisolated context. In case you don't use the context and its associated model instances outside of the current actor, you will be fine. My question is: Is there a recommended way to convert a PersistentIdentifier into a String (to pass to the intent) and then reliably convert that String back into a PersistentIdentifier inside the intent's perform() method? There isn't. In Core Data, NSManagedObjectID provides uriRepresentation(), which returns a URL that can be converted to a string and vice versa. PersistentIdentifier instead exposes an id (ID), which is opaque. The alternative seems to be passing the UUID string
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: