How to solve "No exact matches in call to instance method 'setValue'"
Make sure that the SwiftData variable conforms to the Codable protocol.
Problem
When adding a complex value (i.e. a struct or enumeration) we encountered the following error:
"No exact matches in call to instance method 'setValue'"
- In expansion of macro '_PersistedProperty' here
- Candidate requires that '[complex_value]' conform to 'PersistentModel' (requirement specified as 'Value' : 'PersistentModel')
- Candidate requires that '[complex_value]' conform to 'RelationshipCollection' (requirement specified as 'Value' : 'RelationshipCollection')
Solution
To solve this, we followed Apple's advice and made our complex value abide to the Codable protocol.
Looking to learn more about things you can do with SwiftData, Swift or XCode ?
Consult our quick start guide or search our blog to find educational content on learning how to use SwiftData, Swift or XCode.
Any Questions?
We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.