RE: NSCell's -setStringValue:
RE: NSCell's -setStringValue:
- Subject: RE: NSCell's -setStringValue:
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Tue, 18 May 2004 13:13:29 -0400
>
When i use NSCell's -setStringValue:, what is it actually doing? It's
>
not changing the table's data source, but it is apparently changing the
>
cell's width, because [cell cellSize].width is changing as I change the
>
string value.
>
>
I played around with this using the following code:
>
>
> NSCell *cell = [[myTableView
>
> tableColumnWithIdentifier:@"myIdentifier"] dataCell];
>
>
>
> [cell setStringValue:@"test"];
>
> NSLog(@"cell width = %f", [cell cellSize].width);
>
> [cell setStringValue:@"fibula"];
>
> NSLog(@"cell width = %f", [cell cellSize].width);
The dataCell of a table column does not refer to any particular row of data.
Table columns reuse the same dataCell for each row. It's a prototype. So
changing the value of the dataCell does not change anything in the data
model. I don't think you'll even see the change in the UI.
Table views are not designed so that you can access the data model by
addressing the cells. You are supposed to make changes to the data
directly, and then tell the tableView to -reloadData. This will invoke the
datasource's "getter" method and show the change in the UI if the relevant
row and column are in view.
If you want to directly address the cells, NSMatrix might be a better
choice. There are also some third-party "spreadsheet"-style table view
subclasses. Check the archives.
Jonathan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.