Open inekipelov opened 7 months ago
Can't look into that right away, but RawValue properties are not supposed to be treated as Codable
's. Instead they should just store as their rawValue (e.g. String in this case).
@helje5
Can't look into that right away, but RawValue properties are not supposed to be treated as
Codable
's. Instead they should just store as their rawValue (e.g. String in this case).
Tagged supports both protocols RawRepresentable and Codable Anyway it must works fine? Or I must add additional ValueTransformer?
Same troubles when trying usage enum types
enum AccessLevel: String, Codable {
case selfOnly = "selfonly"
case master
case technical
case financial
}
@Model
final class StoredAccess: NSManagedObject {
var accessLevel: AccessLevel
...
}
Crash
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "accessLevel"; desired type = NSString; given type = _TtGC13ManagedModels10CodableBoxO5WE_UC11AccessLevel_; value = <_TtGC13ManagedModels10CodableBoxO5WE_UC11AccessLevel_: 0x600000030840>.'
Hm, weird. That is pretty much the same I'm doing in the sample app. Though maybe not Codable, that might interfere, need to check.
I'm some change init
code and now have new console crash with fatalError
ManagedModels/PersistentModel+KVC.swift:249: Fatal error: No box found for non-optional Codable value for key token?
I pushed a fix for Codable+RawRepresentable properties to develop, but I didn't try the Tagged thing.
Also did a quick test w/ Tagged, seems to work.
@helje5 Have new error
Could not cast value of type 'Swift.Optional<Any>' (0x1f624fc18) to 'Swift.String' (0x1f6248898).
in PersistentModel+KVC.swift
With the 'develop' branch?
With the 'develop' branch?
yes
Can you produce a mini-project that reproduces that? All tests run through and I tried w/ the demo app w/ success. Please make sure the develop branch is up2date.
Hi @helje5 Thank you for quick solve previous issue
I use Tagged Tagged structure also have Codable protocol realisation like RawValue type Example
When compilation as result we can see
It's strange, because ManagedModels use CodableBox for wrap Codable types. How we can solve it issue in current realisation?