Re: NSTableView delete multiple selected rows
Re: NSTableView delete multiple selected rows
- Subject: Re: NSTableView delete multiple selected rows
- From: Sam Goldman <email@hidden>
- Date: Fri, 14 Dec 2001 23:08:54 -0800
There might be a simpler way (could try to get an NSRange for selected,
dunno if it exists).
It seems to me that this would be pretty simple to imagine, at least if you
have done other programming. Maybe the fact that it's object-oriented is
tripping you up. If so, just think about deleting items in one array from
another.
--------------
int numRows = [tableView numberOfRows] - 1; // I don't remember if I need
to take away 1 or not.
int i = 0;
while(int i < numRows)
{
if ([tableView isRowSelected: i])
[myDataSourceArray removeObjectAtIndex: i];
int i++;
}
[tableView reloadData];
--------------
I don't feel like double checking this. One problem you might want to look
out for is if the indexes of the tableView and data source get out of sync
(it very well might happen in this code). In that case, just move [tableView
reloadData] to the while statement.
- Sam
P.S. Blame Entourage for any formatting that could make the code wrong. I
think I got them all, but I'm not sure.
On 12/14/01 10:39 PM, "Enigmarelle Development" <email@hidden>
wrote:
>
Does anybody have sample code for deleting multiple rows in a table view?
>
I can't use [NSMutableArray removeObjectsInArray] because the list may
>
contain duplicates, which I need to keep; removeObjectsInArray gets rid of
>
them all. I only want to delete the actual selected row indexes.
>
>
There's - (void)removeObjectsFromIndices:(unsigned *)indices
>
numIndices:(unsigned)count which looks like just what I need, but where
>
can I get that pointer from?
>
>
-john c. warner
>
enigmarelle development
>
http://www.enigmarelle.com/
>
_______________________________________________
>
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.