• 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
Re: Pasteboards and NSSecureCoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pasteboards and NSSecureCoding


  • Subject: Re: Pasteboards and NSSecureCoding
  • From: Jeremy Hughes <email@hidden>
  • Date: Wed, 20 Dec 2017 02:22:31 +0000

> On 20 Dec 2017, at 02:07, Quincey Morris
> <email@hidden> wrote:
>
> The class must be a kind of AnyClass, so you can’t specify a struct type.
> Sorry I sent you off in the wrong direction on that.

That’s what I just concluded in an email I started writing.

>> The code I mentioned in my follow-up email seems to work:
>>
>> let array = decoder.decodeObject(of: [NSArray.self], forKey: kArrayKey) as!
>> [Int]
>
> That will compile, but might not work. If you’re doing *secure* decoding then
> the array of types must contain NSArray *and* the type of the elements in the
> array.
>
> However, if you’re not doing secure decoding (and I don’t think you’re
> required to, even if secure encoding was used to create the archive), then
> [NSArray.self] should work.

It compiles and it seems to work. But, as I understand it, NSSecureCoding
refers to decoding rather than encoding (there aren’t any special encoding
functions) so I think I am doing secure decoding. I get an exception if I use
an insecure decoding method, such as:

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

What I don’t like about [NSArray.self] is that it’s an artefact of bridging.
I’m not actually using it in the encoder:

coder.encode(arrayOfInts, forKey: kArrayKey)

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: Jeremy Hughes <email@hidden>
References: 
 >Pasteboards and NSSecureCoding (From: Jeremy Hughes <email@hidden>)
 >Re: Pasteboards and NSSecureCoding (From: Quincey Morris <email@hidden>)
 >Re: Pasteboards and NSSecureCoding (From: Jeremy Hughes <email@hidden>)
 >Re: Pasteboards and NSSecureCoding (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Pasteboards and NSSecureCoding
  • Next by Date: Re: Pasteboards and NSSecureCoding
  • Previous by thread: Re: Pasteboards and NSSecureCoding
  • Next by thread: Re: Pasteboards and NSSecureCoding
  • Index(es):
    • Date
    • Thread