Post

Replies

Boosts

Views

Activity

Reply to Core Data transformable attribute problem in Xcode16
Here is my answer again, with proper punctuation this time :) From my time on Xcode 16.2....with ios18+ As mentioned above there are 2 types of fixes - depends if your 'Transformable' is a 'NSSecureUnarchiveFromData' or a custom one you wrote. For the former things like [String] can be converted to NSArray or [String:Any] can convert to NSDictionary etc. (THE 'NS' bits are critical) For your own custom transformers (say you have a class called 'PermittedTypes' you should have that as an encoding/decoding class and a linked swift file called something like PermittedTypesTransformer.swift In BOTH classes add the line: @objc('the class name) to the line BEFORE the class declaration. Now in xcdatamodel your custom Transformable should be converted from something like [PermittedTypes] to NSArray These technique allows you to keep your strong typing on any transformable, unlike the answers above which suggested [String] or [Int] or anything should become NSArray, rather than NSArray<NS{type}> or NSArray Same works if you are converting arrays, like [String: Any] becoming NSDictionary or [[String:Any]] becoming NSArray
Feb ’25
Reply to Core Data transformable attribute problem in Xcode16
From my time on Xcode 16.2....with ios18+ As mentioned above there are 2 types of ixes - depends if your 'Transformable' is a 'NSSecureUnarchiveFromData' or a custom one you wrote. for the former things like [String] can be converted to NSArray or [String:Any] can convert other NSDictionary etc. (THE 'NS' bits are critical) For your own custom transformers (say you have a class called PermittedTypes' you should have that as an encoding/decoding class and a linked swift file called something like PermittedTypesTransformer.swift IN BOTH classes add the line: @objc('the class name) in the line BEFORE the class declaration. Now in xcdatamoel your custom Transformable should be converted from something like [PermittedTypes] to NSArray This technique allows you to keep your strong typing on any transformable, unlike the answers above which suggested [String] or [Int] or anything should become NSArray, rather than NSArray<NS{type}> or NSArray Same works if you are converting arrays, like [String: Any] becoming NSDictionary or [[String:Any]] becoming NSArray
Feb ’25