Ron*_*nto 5 cocoa objective-c nstableview
我正在尝试实现一个方法来清除所有项目和列的NSTableView.但是当我尝试实现以下内容时,我遇到了崩溃:
- (void)clearResultData
{
[resultArray removeAllObjects];
NSArray *tableCols = [resultTableView tableColumns];
if ([tableCols count] > 0)
{
id object;
NSEnumerator *e = [tableCols objectEnumerator];
while (object = [e nextObject])
{
NSTableColumn *col = (NSTableColumn*)object;
[resultTableView removeTableColumn:col];
}
}
[resultTableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
小智 16
好吧,如果有任何帮助,你可以删除所有列,如下所示:
- (void)removeAllColumns
{
while([[tableView tableColumns] count] > 0) {
[tableView removeTableColumn:[[tableView tableColumns] lastObject]];
}
}
Run Code Online (Sandbox Code Playgroud)