1

I am trying to make a method in which the data source for my NATableView is cleared, but I cannot figure out how to do this anywhere.

Here is the code I am using to send an array called final to my table view.

// I want to clear it here before filling it again.  
for (int i = 0; i < [final count]; i++) {
    [myArrayController addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys:final[i], @"File Name", nil]];
}

Any help would be great!

Andrew Doig
  • 25
  • 2
  • 9
  • Clear like remove all the objects from the array controller? – CodaFi Feb 20 '13 at 18:55
  • Yup exactly, just looking for the command, I think I have the syntax. – Andrew Doig Feb 20 '13 at 18:58
  • possible duplicate of [NSArrayController : removeAllObjects does not refresh TableView](http://stackoverflow.com/questions/3391655/nsarraycontroller-removeallobjects-does-not-refresh-tableview) – CodaFi Feb 20 '13 at 19:01
  • Got the answer from the link above. NSRange range = NSMakeRange(0, [[myArrayController arrangedObjects] count]); [myArrayController removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:range]]; Thanks. – Andrew Doig Feb 20 '13 at 19:06

1 Answers1

0

If you are using an NSMutableArray and myArrayController is your mutable array you want to call

[myArrayController removeAllObjects]; 

before you enter the for-loop.

HAS
  • 19,140
  • 6
  • 31
  • 53