• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Pasteboards and NSSecureCoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pasteboards and NSSecureCoding


  • Subject: Pasteboards and NSSecureCoding
  • From: Jeremy Hughes <email@hidden>
  • Date: Wed, 20 Dec 2017 01:09:44 +0000

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Pasteboards and NSSecureCoding
      • From: Quincey Morris <email@hidden>
    • Re: Pasteboards and NSSecureCoding
      • From: Jeremy Hughes <email@hidden>
  • Prev by Date: Re: Data, enumerateBytes: separate blocks?
  • Next by Date: Re: Creating NSTableView programmatically
  • Previous by thread: Re: Data, enumerateBytes: separate blocks?
  • Next by thread: Re: Pasteboards and NSSecureCoding
  • Index(es):
    • Date
    • Thread