I'm having problems with removeObjectsInArray. I'm just starting off with a new non-document based project trying to get the delete of selected rows in a tableView working and for some reason when I try to delete the selected rows, it clears out my whole array even when I only have 1 row selected to be deleted out of many items.
employeeArray which is a NSMutableArray is alloc-ed and init-ed in the -(id)init of the controller.
When they click add, I create new entries (NSMutableDictionary) in the employeeArray.
Below is my code for deleting and I can't seem to figure out what I'm missing?
Any help appreciated...
- (IBAction)deleteEmployee

id)sender
{
int status;
NSEnumerator *enumerator;
NSNumber *index;
NSMutableArray *tempArray;
id tempObject;
if ( [empTableView numberOfSelectedRows] == 0 )
return;
NSBeep();
status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected record(s)?", @"OK", @"Cancel", nil);
if ( status == NSAlertDefaultReturn ) {
enumerator = [empTableView selectedRowEnumerator];
tempArray = [NSMutableArray array];
while ( (index = [enumerator nextObject]) ) {
tempObject = [employeeArray objectAtIndex:[index intValue]];
[tempArray addObject:tempObject];
}
[employeeArray removeObjectsInArray:tempArray];
[empTableView reloadData];
}
}