Objective c NSMatrix NSArrayController绑定问题--ugh

Objective c NSMatrix NSArrayController绑定问题--ugh,objective-c,cocoa-bindings,key-value-observing,nsarraycontroller,nsmatrix,Objective C,Cocoa Bindings,Key Value Observing,Nsarraycontroller,Nsmatrix,我想操作数组控制器的NSMutableArray属性,该属性作用于NSMatrix的内容,而无需手动将单元格添加到绑定到的NSMatrix 我花了很多时间在这上面,但是没有用 任何帮助都将不胜感激 我在NSListModeMatrix模式下以编程方式创建了一个NSMatrix。在我的NSArrayController子类中,我用4个虚拟对象填充了一个NSMutableArray,表示4行1列数据。然后将填充的NSMutableArray绑定到该矩阵: interface: @property (

我想操作数组控制器的
NSMutableArray
属性,该属性作用于
NSMatrix
的内容,而无需手动将单元格添加到绑定到的
NSMatrix

我花了很多时间在这上面,但是没有用

任何帮助都将不胜感激

我在
NSListModeMatrix
模式下以编程方式创建了一个
NSMatrix
。在我的
NSArrayController
子类中,我用4个虚拟对象填充了一个
NSMutableArray
,表示4行1列数据。然后将填充的
NSMutableArray
绑定到该矩阵:

interface:
@property (nonatomic, strong) NSMutableArray *myArray;

implementation (init):
NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
[bindingOptions setObject:[NSNumber numberWithBool:YES] forKey:NSInsertsNullPlaceholderBindingOption];
[bindingOptions setObject:[NSNumber numberWithBool:YES] forKey:NSRaisesForNotApplicableKeysBindingOption];

[matrix bind:@"content"
    toObject:self
 withKeyPath:@"myArray"
     options:bindingOptions];
现在我想向矩阵中添加列。对于第一次加法,这意味着在位置1,3,5,7处索引的一组单元格,col=1。这是由于
NSMatrix
支持内容数组从左到右、从上到下的特性造成的:

NSInteger colCount = [matrix numberOfColumns];
NSInteger rowCount = [matrix numberOfRows];
NSMutableArray *newList = [[NSMutableArray alloc] init];
NSMutableIndexSet *myIndexes = [[NSMutableIndexSet alloc] init];
for (NSInteger i=0; i<rowCount; i++) {
    [newList addObject:[[NSCell alloc] init]];
    [myIndexes addIndex:col+colCount*i];
}
希望
NSMatrix
将自动更新。但是,唉,没有

我可以
NSLog
确认阵列的大小正在增加(并且布局正确),但除非我执行以下操作,否则UI中不会有任何更新:

// update the `NSMatrix` manually
  [matrix insertColumn:col withCells:newList];
// update the underlying array
  [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:myIndexes forKey:@"myArray"];
  [self.myArray insertObjects:newList atIndexes:myIndexes];
  [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:myIndexes forKey:@"myArray"];
如果省略第一行,则
NSMatrix
完全为空

如果省略第二行和最后一行(
willChange
/
didChange
),保留第一行,则矩阵仅显示默认的单个列

不过,在所有情况下,我都看到底层阵列的大小和排列都在正确增长

但我只想更新底层的可变数组,而不必自己笨拙地向
NSMatrix
添加列

我如何让
NSMatrix
一起玩?

PS:通过这样做,我可以将上述4行缩短为2行,删除遗嘱/遗嘱行:

  [matrix insertColumn:col withCells:newList];
  [[self mutableArrayValueForKey:@"myArray"] insertObjects:newList atIndexes:myIndexes];
  [matrix insertColumn:col withCells:newList];
  [[self mutableArrayValueForKey:@"myArray"] insertObjects:newList atIndexes:myIndexes];