• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
getting the selected object from an NSTableView causes problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting the selected object from an NSTableView causes problems


  • Subject: getting the selected object from an NSTableView causes problems
  • From: Daniel Richman <email@hidden>
  • Date: Fri, 20 Jun 2008 19:51:21 -0700

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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: getting the selected object from an NSTableView causes problems
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Save animation to QuickTime movie?
  • Next by Date: Re: getting the selected object from an NSTableView causes problems
  • Previous by thread: Re: Instance or Class Methods?
  • Next by thread: Re: getting the selected object from an NSTableView causes problems
  • Index(es):
    • Date
    • Thread