RE: Simple NSTableView Question - Newbie
RE: Simple NSTableView Question - Newbie
- Subject: RE: Simple NSTableView Question - Newbie
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Wed, 15 May 2002 13:39:50 -0400
Your tableview shows you an array of "thing" objects. What you want to do
is create a new thing, add it to the array, and then tell the tableview to
refresh itself (reloadData or noteNumberOfRowsChanged). The tableview will
look at the array, notice that there is a new thing, and display an
additional row.
If you want to insert a new object in the middle of your table, call
[tableView selectedRow] and insert the new object at that position in the
array.
The part you seem to be fuzzy on is that this should all be coded in your
controller class, which stands between the view (the tableView) and data
model (MyDataSource). You seem to want the addRow: method to be in the
MyDataSource class. It should be in the controller instead. You don't need
MyDataSource to have a connection to the view. Use the controller to
manipulate both MyDataSource and the view.
Jonathan
>
-----Original Message-----
>
From: email@hidden
>
[mailto:email@hidden]On Behalf Of Michael George
>
Sent: Wednesday, May 15, 2002 11:23 AM
>
To: email@hidden
>
Subject: Simple NSTableView Question - Newbie
>
>
>
Hello!
>
>
I am new to OS X and Cocoa, though I am familiar with OO concepts and
>
I'd played a bit with NEXTSTEP. I come from a Unix background and I am
>
learning Cocoa so that I can develop GUI apps for OS X.
>
>
I have the book "Learning Cocoa" and I am working through it. I am in
>
Chapter 9 and have just finished working with the NSTableView example.
>
>
To expand my knowledge, I want to add a means for adding a new row into
>
the table. I have made a button for adding a row.
>
>
My idea is this:
>
Have the button send the addRow:selector message MyDataSource to add the
>
row.
>
MyDataSource will then add the row and send the noteNumberOfRowsChanged
>
and reloadData messages to the table view.
>
>
However, since the NSTableView contains MyDataSource, there is no handle
>
for finding out which row is selected or sending the messages to the
>
TableView.
>
>
Since NSTableView doesn't have any methods for adding a row (only
>
columns) and there is no delegation or notification for adding a row, I
>
can only presume that my concept of the solution for the problem is
>
wrong.
>
>
This is in the easy part of the tutorials in the book, so I'm sure it's
>
not a difficult problem to solve. I think I'm suffering a mental
>
block...
>
>
If some kind soul would point me in the right direction, I would greatly
>
appreciate it.
>
>
-Michael George
>
Senior Engineer, Software Development
>
Aurora Video Systems, Inc.
>
_______________________________________________
>
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.
_______________________________________________
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.