Post

Replies

Boosts

Views

Activity

Reply to Animatable protocol: no compiler checks for constraints on associatedtype
I found an answer on the Swift community forums, here: https://forums.swift.org/t/checking-constraints-on-associated-types-within-a-protocol/66263/7 In summary, the default implementation of animatableData still exists on the MyAnimatable type, even when that type implements its own animatableData property which does not meet the constraint (does not conform to VectorArithmetic). When trying to read/write to that property, the implementation you access is based on the context from where you perform the operation. I find this counterintuitive, but its good to know.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Animatable protocol: no compiler checks for constraints on associatedtype
I found an answer on the Swift community forums, here: https://forums.swift.org/t/checking-constraints-on-associated-types-within-a-protocol/66263/7 In summary, the default implementation of animatableData still exists on the MyAnimatable type, even when that type implements its own animatableData property which does not meet the constraint (does not conform to VectorArithmetic). When trying to read/write to that property, the implementation you access is based on the context from where you perform the operation. I find this counterintuitive, but its good to know.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23