Core Data : No NSValueTransformer with class name XXX was found for attribute YYYY on entity ZZZZ

后端 未结 1 1591
轻奢々
轻奢々 2021-02-14 08:16

I have my CoreData model set in a xcdatamodel file.

My attribute YYYY has a type transformable and I set the tranformer name in the Data model inspector.

I my

1条回答
  •  你的背包
    2021-02-14 09:02

    I spent way to much time on this to not share the solution I found :

    I had to make the NSValueTransformer subclass available to Objc.

    @objc(LocationArrayTransformer)
    class LocationArrayTransformer : NSValueTransformer {
     ....
    }
    

    Simple as that.


    As @Sbooth points out, Swift classes are namespaced. Using @objc makes the class available without namespacing. So setting the transformer name as MyApp.Mytransformer works well too !

    0 讨论(0)
提交回复
热议问题