cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

NSKeyedUnarchiveFromData deprecated warning #158

Open guojiubo opened 3 years ago

guojiubo commented 3 years ago

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 commented 3 years ago

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

chockenberry commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thanks Craig!

rampatra commented 2 years ago

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.