• 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: Quincey Morris <email@hidden>
  • Date: Tue, 19 Dec 2017 18:07:02 -0800

> On Dec 19, 2017, at 17:38 , Jeremy Hughes <email@hidden> wrote:
>
> let array = decoder.decodeObject(of: [[Int].self], forKey: kArrayKey) as!
> [Int]
>
> gives an error:
>
> Cannot invoke 'decodeObject' with an argument list of type '(of:
> [[Int].Type], forKey: String)’

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.

> 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.
_______________________________________________

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>)

  • 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