I have a table view with 2 columns displaying contents of 2 mutable arrays respectively.
I added a button to remove the selected row and ultimately the arrays objects at index of selected row. I have the button properly linked to class method:
@implementation TableController
-(IBAction)remove:(id)sender{
NSInteger row= [tableView selectedRow];
[_trackNames removeObjectAtIndex:row];
[_trackNumber removeObjectAtIndex:row];
[tableView reloadData];
}
The tableView datasource methods
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
return self.trackNames.count;
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
if ([tableColumn.identifier isEqualToString:@"Track"]) {
return [self.trackNumber objectAtIndex:row];
}
else{
return [self.list objectAtIndex:row];
}
}
When running the app, clicking the remove button does not do anything.
Is the problem due to the presence of two arrays?that the tableView would get conflicted.
should I use method - reloadDataForRowIndexes:columnIndexes:
for both arrays instead?
Edit
here are the arrays used to populate the table view. (tableView displays their contents correctly, no flaws here I guess)
-(NSMutableArray*)trackNames{
NSString *pathDataTableView = @"TrackSelectorData/ArrayTableView.plist";
_trackNames = [NSMutableArray arrayWithContentsOfFile:pathDataTableView];
return _trackNames;
}
-(NSMutableArray*)trackNnumber{
_trackNumber = [[NSMutableArray alloc]init];
for (NSInteger i = 0; i < [_trackNames count]; i++){
[_trackNumber addObject:[NSNumber numberWithInteger:i+1]];
}
return _trackNumber;