我有一个NSTableView
里面充满了来自程序的数据。我有一个重置按钮,除了用于程序的其他部分之外,should清除NSTableView
的数据。
但是,我完全不知道该怎么做。我还在学习 Obj-C。
您可以通过调用从 NSTableView 中一一删除对象removeRowsAtIndexes:
(文档在这里 https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSTableView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTableView/removeRowsAtIndexes%3awithAnimation%3a)然后调用reloadData
在 NSTableView 上。
如果您想清除所有数据,则需要清除数据源(通常是为表提供数据的 NSArray),然后调用reloadData
。要清除数据源,如果它是 NSDictionary 或 NSArray,请调用removeAllObjects
在 NSDictionary 或 NSArray 上。以下是您可以执行的操作的示例:
[myDataSourceDictionary removeAllObjects];
[myTableView reloadData];
看一眼Apple 关于 NSTableView 的文档 https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSTableView_Class/Reference/Reference.html too.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)