Re: Pasteboards and NSSecureCoding
Re: Pasteboards and NSSecureCoding
- Subject: Re: Pasteboards and NSSecureCoding
- From: Quincey Morris <email@hidden>
- Date: Tue, 19 Dec 2017 17:25:05 -0800
On Dec 19, 2017, at 17:09 , Jeremy Hughes <email@hidden> wrote:
>
> 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)
That looks like Swift 3 code. The current version of the function is like this:
> @nonobjc func decodeObject(of classes: [AnyClass]?, forKey key: String) ->
> Any?
so you’d specify [NSArray.self, <something>.self] for the first parameter.
(Note, it’s a Swift-specific wrapper function, not just a direct API
translation.)
You’ll have to figure out what type to use for the Ints. If they were actually
saved compatibly with Obj-C, the Ints will actually be NSNumbers, and you’ll
need to say “NSNumber.self”. If the Ints are stored opaquely as Ints, I guess
it would be Int.self. You should be able to figure out the right type by trial
and error, I’d say.
(Actually, if the array itself was saved opaquely, then you’ll need something
like [[Int].self], I guess. This is an area subject to automatic bridging, so
what you get depends on the exact code used to encode the archive.)
_______________________________________________
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