9.5 C
New York
Tuesday, March 11, 2025

iOS Swift Core Knowledge NSSecureUnarchiveFromDataTransformer points


I’ve up to date my app to make use of NSSecureCoding. Nevertheless, this has launched a bunch of faults/points.

I’ve apparently efficiently up to date all of the mannequin courses to work. My datamodel has an entity with one “transformable” attribute which is an array of a customized class, which itself accommodates many customized courses. If I exploit the generic transformer I efficiently retailer the whole lot in Core Knowledge nonetheless I get warnings like this:

enter image description here

*** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving protected plist kind ''NSString' (0x203af77c0) [/System/Library/Frameworks/Foundation.framework]' for key 'uuid', despite the fact that it was not explicitly included within the consumer allowed courses set: '{(
    "'Exercise' (0x102341358) [/private/var/containers/Bundle/Application/2B2CEB45-F110-47DF-91BB-8774C0A703A9/Pyth14.app]",
    "'NSArray' (0x203aefc48) [/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This can be disallowed sooner or later.

If i exploit the customized transformer inherited from NSSecureUnarchiveFromDataTransformer then I get code faults and my information is not saved in core information, with the next errors (and I nonetheless get the aforementioned warnings).

enter image description here

fault: exception raised throughout multi-threaded fetch  threw whereas decoding a price. ({
NSUnderlyingError = "Error Area=NSCocoaErrorDomain Code=4864 "worth for key 'begin' was of surprising class 'NSDate' (0x203aef810) [/System/Library/Frameworks/CoreFoundation.framework].nAllowed courses are:n {(n    "'Exercise' (0x102341358) [/private/var/containers/Bundle/Application/2B2CEB45-F110-47DF-91BB-8774C0A703A9/Pyth14.app]",n    "'NSArray' (0x203aefc48) [/System/Library/Frameworks/CoreFoundation.framework]"n)}"

Making an attempt to hint down the difficulty it appears to be like like one way or the other the transformer is not studying the proper “allowedTopLevelClasses” and the most effective tracing I have been capable of do is put a print assertion to make sure that, in reality, the transformer has the listing of courses I gave it.

What I can inform is that the fault is for the contained class (exercise) within the array, so my finest guess is that the contained courses themselves want their very own transformer – I attempted creating an attribute for the Exercise class and making a transformer BUT I nonetheless get the very same error message.

Sadly, the documentation is nonexistent, and the 1, sure just one, on-line article I may discover is just a easy instance of a transformer (not one which has objects nested in objects).

That is associated to the difficulty:
Core Knowledge & Xcode 11: Please change to utilizing “NSSecureUnarchiveFromData” or a subclass of NSSecureUnarchiveFromDataTransformer

And I tried to do the whole lot talked about in the one on-line article (additionally talked about within the above linked SO query). https://www.kairadiagne.com/2020/01/13/nssecurecoding-and-transformable-properties-in-core-data.html

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles