The release notes for 10.13 say:

If your application is linked on macOS 10.13 SDK or later, classes that return 
NSPasteboardReadingAsKeyedArchive from readingOptionsForType:pasteboard: must 
support secure coding, and will be decoded with a coder that requires secure 
coding.

So I’m updating some of my classes to support NSSecureCoding, and I’m having 
trouble figuring out how I should decode an array of Ints.

Previously, I had:

let array = decoder.decodeObject(forKey: kArrayKey) as! [Int]

I think that I need to replace that with something like:

let array = decoder.decodeObject(of: allowedClasses, forKey: kArrayKey) as! 
[Int]

but I can’t work out how to define allowedClasses.

In a previous discussion, Quincey Morris wrote:

> The solution is to fall back to an explicit NSSet object:
> 
>       let classes = NSSet (objects: NSArray.self, MyElementClass.self)
>       let myArray = coder.decodeObjectOfClasses (classes, forKey: “myArray”)

So I’ve tried:

let allowedClasses = NSSet(objects: NSArray.self, Int.self)

But I get an error: Cannot invoke 'decodeObject' with an argument list of type 
'(of: NSSet, forKey: String)’

I also think there should be a way of doing this that uses Array and Set rather 
than NSArray and NSSet

Jeremy


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to