Post

Replies

Boosts

Views

Activity

Reply to SwiftData History Tombstone Data is Unusable
I have managed to get out the dictionary using reflection, guess this will do as a temporary workaround, but kind of strange that the api does not match the WWDC video or documentation. For people running into the same thing, this works until the API is actually there (just do not use this in production): extension History.Tombstone { subscript<T>(keyPath: KeyPath<Model, T>) -> T { let mirror = Mirror(reflecting: self) guard let storageChild = mirror.children.first(where: { $0.label == "storage" }), let dictionary = storageChild.value as? [PartialKeyPath<Model> : Any], let value = dictionary[keyPath] as? T else { fatalError("Missing expected tombstone value for \(keyPath)") } return value } }
Jun ’24