在 Aaron Hillegass 的Cocoa Programming for Mac OS X中,Raiseman 应用程序将 Interface Builder (IB) 中的按钮连接到NSArrayControllerwith sent action -remove:。在 MyDocument 类中,他实现了两个 KVC 方法:
- (void)insertObject:(Person *)p inEmployeesAtIndex:(int)index;
- (void)removeObjectFromEmployeesAtIndex:(int)index;
按下此按钮时,将-removeObjectFromEmployeesAtIndex:调用该方法并从数组中删除当前选定的 Person (Model) 对象。
- IB中使用的方法如何
remove:导致-removeObjectFromEmployeesAtIndex:方法被调用? - 如何用 重现这种效果
NSTreeController?