Re: Pasteboards and NSSecureCoding

2017-12-20 Thread Jeremy Hughes
Thanks for your detailed comments! Something I’ve realised through this is that you need to be really careful about upgrading your system on a development machine. Going from 10.12 to 10.13 - and finding that pasteboard functions compile just fine but no longer work - is almost as big a jump

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Quincey Morris
On Dec 19, 2017, at 18:32 , Jeremy Hughes wrote: > >> On 20 Dec 2017, at 02:22, Jeremy Hughes > > wrote: >> >> What I don’t like about [NSArray.self] is that it’s an artefact of bridging. >> I’m not

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
> On 20 Dec 2017, at 02:22, Jeremy Hughes wrote: > > 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) The declaration: encode(_ object: Any?,

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
> On 20 Dec 2017, at 02:07, Quincey Morris > 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

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Quincey Morris
> On Dec 19, 2017, at 17:38 , Jeremy Hughes 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)’

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
> On 20 Dec 2017, at 01:25, Quincey Morris > wrote: > > 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

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
Thanks, Quincey. > 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? @nonobjc means this is Swift-specfic then? The init function I’m using is marked as @objc: @objc

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
It seems that I can write: let array = decoder.decodeObject(of: [NSArray.self], forKey: kArrayKey) as! [Int] But shouldn't I be able to specify that this is an array of Ints, and not just an array of anything? I should probably avoid force unwrapping - this ought to be a failable

Re: Pasteboards and NSSecureCoding

2017-12-19 Thread Quincey Morris
On Dec 19, 2017, at 17:09 , Jeremy Hughes 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 =