Re: Creating NSTableView programmatically
Re: Creating NSTableView programmatically
- Subject: Re: Creating NSTableView programmatically
- From: Quincey Morris <email@hidden>
- Date: Tue, 19 Dec 2017 12:32:13 -0800
On Dec 19, 2017, at 02:24 , Eric Matecki <email@hidden> 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 that it's impossible to tell
whether your code is any more than locally correct (that is, beyond whether
each line of code does what it purports to do). But all that aside…
— I think it’s a tragic mistake to subclass a NSArrayController. The class is a
largely inscrutable black box of glue code, and any code that you add is thrown
into the black hole. (I admit this is only an opinion. Others may love this
kind of self-inflicted pain.)
— I think it’s *probably* a mistake to use NSArrayControllers *at all* in this
project, where you’re trying to implement a specific UI. A NSArrayController is
a generalized collection of behaviors intended to be used to support a large
generality of UI designs in a NIB file. That level of generality isn’t
necessary when you’re writing UI code directly, without using NIBs. It’s the
equivalent of using a dictionary with string keys to represent properties,
instead of declaring the actual properties you want.
— Your actual problem is that selection doesn’t work because you didn’t connect
up the right pieces to make it work. For example, I fixed it for the first
table by adding one line of code in the “buildGUI” method:
> [combatantsTable bind: @"content" toObject: self.combatantsController
> withKeyPath: @"arrangedObjects" options: 0]; // existing code
> [combatantsTable bind: @"selectionIndexes" toObject:
> self.combatantsController withKeyPath: @"selectionIndexes" options: 0]; //
> added code
IOW, the array controller doesn’t know what the current selection is unless you
tell it. I didn’t try to fix any of the other tables, but presumably they have
the same problem.
_______________________________________________
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