Re: Pasteboards and NSSecureCoding
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