Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

NSKeyedUnarchiveFromData deprecated warning #158

Open
guojiubo opened this issue Mar 18, 2021 · 5 comments
Open

NSKeyedUnarchiveFromData deprecated warning #158

guojiubo opened this issue Mar 18, 2021 · 5 comments

Comments

@guojiubo
Copy link

Looks like NSKeyedUnarchiveFromData is deprecated by Apple and I'm hitting this warning(console log):

[general] 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release

Nice library btw, thanks for your awesome work.

@shpakovski
Copy link
Collaborator

@guojiubo Thanks for the heads up! Could you please make a pull request?

@chockenberry
Copy link
Contributor

I ran into the same problem and determined that MASDictionaryTransformer was the way to go.

If you fix the deprecation warning and use NSSecureUnarchiveFromDataTransformerName, it will leave you in a situation where your customer has data in the old format and the secure unarchive will fail (and throw an exception in the process).

It would be possible to do a one-time conversion from insecure to secure data, but this is tricky to detect (since you have to dig around in the data to determine when to perform the conversion.)

Instead, we just renamed the preference key and migrated to the dictionary transformer instead. It's easier to read, more compact, and I think it should be the default for this framework now.

@chockenberry
Copy link
Contributor

Also forgot to mention that secure coding only allows for NSArray, NSDictionary, NSSet, NSString, NSNumber, NSDate, NSData, NSURL, NSUUID, and NSNull as top-level objects. So you'll be convertingMASShortcut to something else during the transform - easier just to use the dictionary.

@shpakovski
Copy link
Collaborator

Thanks Craig!

@rampatra
Copy link

rampatra commented Mar 9, 2022

Was there a PR for this? I have started to get the same warnings too.

I am a novice Objective-C/Swift coder so I may not be the best person to create a PR for this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants