Hi,
I have an NSTableView and NSArrayController working with an NSMutableArray just fine but i'd like the TableView to display/edit different sets of data depending on a setting in my code.
This is what I have right now, with the TableView working with the data in currentGroupArray.
I would like to be able to chage the TableView change to use one of the other three NSMutableArrays programatically.
I've tried just assigning currentGroupArray to one of the other three, but that breaks the model of only having the ArrayController access the MutableArray (I think).
I've also tried making the Model Key Path of the ArrayController call a getter method for currentGroupArray that selects one of the other three arrays, but this didn't work at all.
I can think of two other ways to do this but I'm hoping there's a better way.
1) I can swap objects in & out of the currentGroupArray using the ArrayController's addObject everytime I change which array to display but this seems clumsy.
or
2) Maybe have a seperate NSArrayController for each of the three NSMutableArrays?
What's the correct way to go about this?
I have an NSTableView and NSArrayController working with an NSMutableArray just fine but i'd like the TableView to display/edit different sets of data depending on a setting in my code.
This is what I have right now, with the TableView working with the data in currentGroupArray.
Code:
NSMutableArray *groupArrayOne;
NSMutableArray *groupArrayTwo;
NSMutableArray *groupArrayThree;
NSMutableArray *currentGroupArray;
IBOutlet NSTableView *groupTableView;
IBOutlet NSArrayController *groupController;
I would like to be able to chage the TableView change to use one of the other three NSMutableArrays programatically.
I've tried just assigning currentGroupArray to one of the other three, but that breaks the model of only having the ArrayController access the MutableArray (I think).
I've also tried making the Model Key Path of the ArrayController call a getter method for currentGroupArray that selects one of the other three arrays, but this didn't work at all.
I can think of two other ways to do this but I'm hoping there's a better way.
1) I can swap objects in & out of the currentGroupArray using the ArrayController's addObject everytime I change which array to display but this seems clumsy.
or
2) Maybe have a seperate NSArrayController for each of the three NSMutableArrays?
What's the correct way to go about this?