Table View

How do I set the rows of a table and get the values of a tick box column? Part 2 is a bit large to understand and uses bindings, which I don’t tend to use. Are bindings needed to make it much less complicated? I know there is some sort of alloc init thing but I can’t figure out how anything works. It’s just a title column and a tick column already done in IB and I would use a normal AS list for the rows, but if needed it is convenient to get a Objective-C type list of them. Please help.

Hi Richard,
I battled it out with tables for weeks finally getting it all working with bindings. But look at craig’s Booklist app example-tutorial. It had a simple table and set and get values from it. Not sure about the check box but that shouldn’t be hard once you set the table going.

Here is the long post about my table exploits:

if that helps.


OK bindings will do, I don’t see anything else.

I’ve tried my best to understand it but I don’t understand the input/output of these delegate methods or how craig works with them in part 2.

What I have so far is here:

The table code is at the bottom of choosefromlistcontroller, you can see the links, there are no bindings, the addData is triggered by finishing editing the token field (just click in the prompt box or something), there are many errors. Please help!

I have the setting part worked out by using bindings and an array controller, but how do I get the values of the table including tick boxes? When I try getting the array binding’s value, it doesn’t include changes to tick boxes.

Anybody? :frowning:

Cells with checkboxes should be set to boolean values, if that’s what you mean. But I’m struggling to follow exactly what you’re talking about…

…How do I get the current content of the table?.. meaning for example I set it to:

{{valbwinfile:“.txt”, valbwingen:“Document”, valbwinallo:false}, ¬
{valbwinfile:“.rtf”, valbwingen:“Document”, valbwinallo:false}, ¬
{valbwinfile:“.rtfd”, valbwingen:“Document”, valbwinallo:false}, ¬
{valbwinfile:“.pages”, valbwingen:“Document”, valbwinallo:false}}

…but I click rtf so it is then…

{{valbwinfile:“.txt”, valbwingen:“Document”, valbwinallo:false}, ¬
{valbwinfile:“.rtf”, valbwingen:“Document”, valbwinallo:true}, ¬
{valbwinfile:“.rtfd”, valbwingen:“Document”, valbwinallo:false}, ¬
{valbwinfile:“.pages”, valbwingen:“Document”, valbwinallo:false}}

…how can I retrieve the tables current array? It is set up with an Array Controller like on the scripting matters site.

If you’ve used bindings, you don’t have to do anything – the value has changed in the bound variable.

When I log it it shows up as the standard values. If you like take a look, on choose file view check some rows, click the minus and you won’t see anything but 0s for valbwinallo.

Edit: Oops, remove the as string from subremtype.

You’re not likely to get much help with so much code and no real explanation. You’ll have to cut it down, or put in log entries, and give some idea of what you’re doing where.

One obvious thing to try: in the bindings, click on Validates immediately.

Well in ChooseFileController you have the valdeftypes property which is all the default table data, cffinishlaunching (which gets call by the AppDelegate finish launching handler) sets the binding to the default data plus custom data from a text file which is blank, so don’t worry about custom stuff. There is the subaddtype hander for the add button and stuff under the table which adds items, temporarily the minus button and subremtype logs the binding for my testing. I need the check values for subcalc (triggered by preview, copy, insert).

Checking all the 'validates immediately’s didn’t help.

Bump, can nobody help, please, I’d be so grateful :frowning:

I spent more than 30 minutes trying to define your problem, and gave up. Sorry, but you’re unlikely to get any help unless you help the helpers by adding clear and detailed explanatory notes, deleting all irrelevant code, and adding logging to show the problem. I know that’s a lot of work, but so is diving into someone else’s large project cold.

Thanks for your time and effort. New, same link, is that enough info?

Still far too much – you need to remove all the extraneous stuff. My guess is that turning on Handles Content as Compound Value in the Array Controller’s binding will solve the problem. This was discussed around here before.

Thank you, perfect, next thing will be selection, but can wait till I need to know :slight_smile:

I am stuck at understanding how to read the contents of the selectedRow in the Table View that has been bound to an Array in IB.

I am able to retrieve the clickedRow or selectedRow, but if I change the order of the Table View, the selectedRow is not in the same order at the Array.

Bindings seemed to be easy at first, but I am stuck on this one. I can lock the Table View down, but if I want to incorporate a search filter, I’ll need to figure out how to translate the double clickedRow to the data in the array that its bound to.

--delegate properties:
--	property parent : class "NSObject"
--	property ChannelData : missing value
--	property MyTable : missing value

on awakeFromNib()
		set my ChannelData to {{Channel:"Loading Channel Data...", ChID:"StandBy"}}
                -- channel data loads @applicationWillFinishLaunching_(aNotification)
		-- Set double-click action on table view
		MyTable's setDoubleAction_("DoubleClickedAction")
end awakeFromNib

on DoubleClickedAction()
		set MyRow to (MyTable's clickedRow as integer)
-- this works, but cannot rearrange the TableView in the UI this way

		if MyRow ≠ -1 then
			set myItem to item (MyRow + 1) of my ChannelData
			set IDx to ChID of myItem
end DoubleClickedAction

I don’t know how to get the ChID Key from the selectedRow or clickedRow when the TableView is not in the same order from my ChannelData array which the TableView is bound to in IB.

Are you using an NSArrayController?