Hi All,
I've got an NSTableView that displays the data in an NSMutableArray.
(The program is a to-do list.) I just tried adding a function to allow
you to delete an item: you select the item in the table and then click
delete. My code is as follows:
- (IBAction)deleteItem:(id)sender
{
int selectedRow = [((NSNumber *)[tableView selectedRow]) intValue];
NSLog(@"Selected row is %d", selectedRow);
if (selectedRow != -1) {
NSLog(@"Deleting '%@'", [toDoList objectAtIndex:selectedRow]);
[toDoList removeObjectAtIndex:selectedRow];
[tableView reloadData];
}
}
The problem is that if I try to delete any item other than the very
first one (index 0), the program crashes. I did some log work, which
revealed that the first line is causing problems (int selectedRow...).
But that doesn't explain why the deleting the first item works ok. I'm
stumped. Any ideas?
My project is online at
http://danielrichman.com/tmp/DataSourceChallence_ToDoList.zip .
Thanks,
--Daniel
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]