Update value of NSDictionary Item in NSMutableArray

Hey guys… so my problem is probably something silly, but here goes…
I have a table view with it’s datasource being an NSMutableArray.
When the user clicks on a row, I can retrieve the row by using the following code:

set curRow to myDataSource’s objectAtIndex_(DataView’s selectedRow())

But if I try to update the third column whos identifier is “column3” using the following code:

curRow’s setValue_forKey_(“column3”, “This is a test”)

nothing happens. No error is generated… I’ve checked everything… It just won’t update the value of the cell for the current row.
If I create a new NSMutableArray and copy all the values and set the row I want to the new value and then replace the old array with the new one it works… but that is extra work for such a simple task.

Did I miss something or is there a setting I’m not using?

Any help will be highly appreciated!

Julio.

Are you using an NSArrayController? If so, just check Handles Content As Compound Value.

No. Im not using an NSArrayController…
Should I be?

It’s all simple NSMutableArray in code as AppleScript.
Here is the initialization routine of the NSMutableArray:

set myDataSource to NSMutableArray’s alloc()'s init()

The applescript file is set as the DataSource of the TableView
Everything else works perfectly. I can delete rows.
I can clear the entire thing and load data from a text file.

I’m really not sure why it won’t let me update the string value of a cell…
I’m accessing it through the datasource object ( NSMutableArray ), not the table view…
I can return the values to the log so I know I’m accessing the values correctly.
Like I said if I make a duplicate NSMutableArray and run through the values copying them from the
old array to the new one and making only the change I want when I get to the row I want to edit it works.
I then clear the old array and copy in the new one and it works. The data is updated…

This just seems like such a waste of processing time and code.
Plus if the datasource object is huge, like 433,134 entries which I will soon have to address
this will be really badly handling data and memory.

Are you actually using your script as the data source – by that, I mean are you implementing the NSTableViewDataSource protocol, or are you using bindings to populate the table? The easiest way to implement a table is with bindings and an array controller. You don’t have to use an array controller, but it makes some things easier if you do.

Ric

No I’m not using bindings to populate the table.
This project was a rebuild of something I did back in 06.
My client demanded that I updated it, so I did for a fee.
I don’t really have the time or budget to rebuild this out now…

I created 2 datasources for 2 table views.
The main script is the datasource for one table view
and another script is the datasource for the other table view.
I can populate both tables with data. I can do wholesale changes on the data.
I can clear all the data and repopulate the table with new data.

I just cant change a single field… this shouldn’t be this hard…

The methods for NSDictionary:
[NSDictionary valueForKey: @“MyIdentifier”]

works fine but

[NSDictionary setValue: VALUE forKey: @“MyIdentifier”]

does not… why is that?

Hi,

the normal way to update a table view without bindings is to change the value in the datasource array and
call the method reloadData: of NSTableView

Thank you for the suggestion… but I have already tried that.
For whatever reason it’s just not working.
I’ve updated the value of the data source and then called the reload data method to no avail.

Nevermind. Here is what I did to solve it:

I created a new NSDictionary, I copied the data from the records of the selected row that needed to stay the same and updated the selected record with the updated data and then I used the method:

replaceObjectAtIndex_withObject_(DataView’s selectedRow(), newRow)

Then I called reloadData and it’s all working. Thanks again guys for your efforts in trying to help me.
I really do appreciate it.