I am storing UIBezierPaths in CoreData. To do this, I have to set the type of the field to Data; I wasn't able to get Transformable to work, and this does.
However, I get an error thrown in the encoding/decoding process when I retrieve or store these paths. The error is
2021-11-02 09:08:39.138674+0700 TestSVG[82461:1408543] [general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
The methods that I'm using based on help provided here, are:
func bezierToData(path: UIBezierPath) -> Data? {
do {
return try NSKeyedArchiver.archivedData(withRootObject: path, requiringSecureCoding: false)
} catch {
return nil
}
}
func dataToBezier(src: Data) -> UIBezierPath? {
do {
return try NSKeyedUnarchiver.unarchivedObject(ofClass: UIBezierPath.self, from: src)!
} catch {
return nil
}
}
This seems to have been something that multiple changes have been imposed on by Apple. My needs are very simple, and what I'm doing works perfectly, but of course I don't want to run into future problems.
This answer : 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release applies to objects that are storable as Transformable, which I could not get working. Again, the advice here was to use Data and that has worked.
I've read all the answers that I can here and elsewhere, and because, basically, StackOverflow usually prioritizes answers accepted immediately after the question was asked, and has no method of updating when the accepted answer becomes obsolete… it can be a burning dumpster of confusion when it comes to getting relevant answers, at least for relative newbies like moi.
But I digress. Can anyone point me to current practice that will allow me to simply serialize and deserialize UIBezierPaths into a CoreData store?