TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

NSSecureUnarchiveFromDataTransformer help

Forums > Swift

I'm updating an app and discovered that with iOS 14 and core data, when using a transformable attribute, I can no longer use the standard value transformer and have to write my own. That was fairly straightforward and implementing it was also straightforward.

In the core data definition you have to name the value transformer and this is where my problem begins. In order to support iOS versions earlier than 12 (I need to go back to 10), I need to subclass from the ValueTransformer class. In iOS 12 I can use NSSecureUnarchiveFromDataTransformer (which inherits from ValueTransformer) and beginning with iOS 14 this class is required to sublcass from otherwise the compiler complains its not secure.

How can I name the value transformer type in core data to support iOS 10 and 11 and dynamically, at run time, switch to the other value transformer?

2      

Hacking with Swift is sponsored by Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.