Transformable attributes are a immutable type, therefore cannot be changed. The only way of changing them is by creating a new object and saving it again to core data.
To solve this I deleted the property cartItemAttribute from my xcdatamodel which holds both a product and a quantity as one transformable attribute. I replaced it with a product attribute of type transformable and a quantity attribute of type Int and everything works fine now.
funccomplexSuccess() { // make sure that the device supports haptics guardCHHapticEngine.capabilitiesForHardware().supportsHaptics else { return } var events = [CHHapticEvent]()
// create one intense, sharp tap let intensity =CHHapticEventParameter(parameterID: .hapticIntensity, value: 1) let sharpness =CHHapticEventParameter(parameterID: .hapticSharpness, value: 1) let event =CHHapticEvent(eventType: .hapticTransient, parameters: [intensity, sharpness], relativeTime: 0) events.append(event)
// convert those events into a pattern and play it immediately do { let pattern =tryCHHapticPattern(events: events, parameters: []) let player =try engine?.makePlayer(with: pattern) try player?.start(atTime: 0) } catch { print("Failed to play pattern: \(error.localizedDescription).") } }