OS X: Sorting NSTableView binding to NSArrayController -
i have nstableview bind nsarraycontroller. i'm sorting nstableview , works fine when click on row of nstableview different value nsarraycontroller not been sorted.
here how i'm sorting nstableview:
nssortdescriptor *sd = [nssortdescriptor sortdescriptorwithkey:@"names" ascending:yes]; [self.names setsortdescriptors:[nsarray arraywithobject:sd]];
for example when click on name1 value of name2. need match values of nstableview nsarraycontroller. of knows i'm doing wrong? or how can sort both nstableview , nsarraycontroller ?
i'll appreciate help
when click on name1 value of name2
how value?
i suspect you're looking in wrong place.
first, should bind table view's selectionindexes
binding array controller's selectionindexes
property. likewise, should bind table view's sortdescriptors
binding array controller's sortdescriptors
property.
it's not clear self.names
refers in code. table view or array controller? personally, set sort order of table view setting array controller's sortdescriptors
.
anyway, after set up, when want selected object(s), have consult array controller, not model may providing content of array controller. (you didn't say, i'll assume array controller's contentarray
binding bound indexed collection property in model.)
first, can query selectedobjects
property.
alternatively, if you're starting row index, must use index arrangedobjects
.
you must not take row or selection index , index indexed collection property of model. array controller has rearranged objects before providing them table view (based on sort descriptors and, possibly, filter predicate). so, indexes no longer correspond original indexed collection in model.
Comments
Post a Comment