2nd table array linked to 1st table selection, updating
2nd table array linked to 1st table selection, updating
- Subject: 2nd table array linked to 1st table selection, updating
- From: Chris Paveglio <email@hidden>
- Date: Fri, 21 Oct 2011 09:16:27 -0700 (PDT)
If this sort of thing has be discussed before I'm sorry. Shoot me a link to the other discussion or sample code.
My app watches several folders (and subfolders) on our file servers, and counts and displays the files in those folders.
I have a class for the folder data that contains the count from 3 subfolders (ints) and then an array of file names of the files from one of the subfolders.
There are 8 folders that are watched, and those 8 items are in an array. I have a table view that has columns for the integer values from the class object. Then there is a second table where I show the file names when the user selects a row from the first table.
I have both these tables set up using bindings and array controllers. The first table is straight forward setup. The second one's content array is bound to the first array controller. The controller key is "selection" and the model key path is the name of the array in the class object.
The second table shows up fine, and it's content changes when I change the selection on my first table.
But when the contents of the folder changes and the app recalculates the data, I get an error that *** -[NSCFArray objectAtIndex:]: index (3) beyond bounds (3)
This only occurs when the first table has a selection, and I understand (probably) that it's because the second table is based on the first, and that the data for the 2nd table is changing in a non-KVC compliant kind of way. I'm not telling the 2nd array controller to remove or reset the values in the class object's array, I am just directly removing all the objects from class object array, then re-adding the newly scanned file names into the array.
My workaround is, in code, the first table is deselected, the values are all updated, and then the originally selected row is reselected. This makes the display function and update properly.
So my question is, is there a more elegant sort of way to do this kind of multi-table display, using bindings and selections?
Thanks,
Chris
_______________________________________________
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