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 actually using it in the encoder: >> >> coder.encode(arrayO

Re: 10.13 printing problem

2017-12-19 Thread Jeremy Hughes
> On 19 Dec 2017, at 18:03, Jeremy Hughes wrote: > > I have a problem printing an autolayout view in 10.13.2, and I’m wondering if > there is something wrong with my code or if Apple broke something in 10.13 or > a more recent update. > > I’m using the same view class for printing and screen,

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?, forKey key: String) seems to

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 code I mentioned in my follow-up email se

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)’ The class must be a kind of AnyC

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 are stored opaquely as > Ints, I gue

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 requir

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 initializer,

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 = coder.decodeObjectOfClasses (clas

Re: Creating NSTableView programmatically

2017-12-19 Thread Richard Charles
> Eric Matecki - Combatants Project on GitHub > > File Combatants.m > > /* > Create and return an array of all the combatants that are not selected > */ > - (NSArray *) arrangeObjects: (NSArray*)iObjectsToArrange > { > printf("Targets::ArrangeObject()\n”); This smells like C++ which is ok

Pasteboards and NSSecureCoding

2017-12-19 Thread Jeremy Hughes
The release notes for 10.13 say: If your application is linked on macOS 10.13 SDK or later, classes that return NSPasteboardReadingAsKeyedArchive from readingOptionsForType:pasteboard: must support secure coding, and will be decoded with a coder that requires secure coding. So I’m updating som

Re: Data, enumerateBytes: separate blocks?

2017-12-19 Thread Quincey Morris
On Dec 19, 2017, at 14:57 , Daryle Walker wrote: > > What are the hoops/bridges required? I think I was referring to what Wim Lewis said, which is that you can create DispatchData values (or perhaps dispatch_data_t objects), but you’re going to have to forcibly cast from dispatch_data_t to its

Re: Data, enumerateBytes: separate blocks?

2017-12-19 Thread Daryle Walker
> On Nov 28, 2017, at 3:54 PM, Quincey Morris > wrote: > > I believe that there is one more little piece to this that’s more recent. > Since (after that 10.9 change) the NSData class had to become (publicly) > aware that subclasses might contain discontiguous data, the opportunity arose > fo

Re: Creating NSTableView programmatically

2017-12-19 Thread Quincey Morris
On Dec 19, 2017, at 02:24 , Eric Matecki wrote: > > When I select a row in a NSTableView, that selection doesn't "make it" all > the way to update the controller... I masochistically downloaded your project, and I think it’s a perfect example of why not to do this. There is so much glue code t

10.13 printing problem

2017-12-19 Thread Jeremy Hughes
I have a problem printing an autolayout view in 10.13.2, and I’m wondering if there is something wrong with my code or if Apple broke something in 10.13 or a more recent update. I’m using the same view class for printing and screen, but I have a separate view object for printing. I’m overridin

Re: Creating NSTableView programmatically

2017-12-19 Thread Eric Matecki
On 19/12/2017 11:24, Eric Matecki wrote: Hello all, No I didn't abandon all hope, I was just busy :) Thanks to all the replies, I got a lot further, but still didn't reach my destination... Now I have a nice window, looking almost exactly like the NIB created one. Most things works, except t

Re: Creating NSTableView programmatically

2017-12-19 Thread Eric Matecki
Hello all, No I didn't abandon all hope, I was just busy :) Thanks to all the replies, I got a lot further, but still didn't reach my destination... Now I have a nice window, looking almost exactly like the NIB created one. Most things works, except the most fundamental one. When I select a r