How to update NSTableView without using -reloadData?

前端 未结 5 1746
猫巷女王i
猫巷女王i 2021-02-02 15:29

I am new to the Mac. I am trying to update a particular cell in NSTableView without using -reloadData, as -reloadData updates the whole table. I have t

5条回答
  •  情歌与酒
    2021-02-02 15:37

    A full example of using reloadDataForRowIndexes to update all rows but only a single column:

    int col = 2 ;
    [self.myTable reloadDataForRowIndexes:
        [NSIndexSet indexSetWithIndexesInRange:
            NSMakeRange(0,self.myTable.numberOfRows)] 
        columnIndexes:
            [NSIndexSet indexSetWithIndex:col]
    ];
    

    Or all columns for a single row:

    int row = 2 ;
    [self.myTable reloadDataForRowIndexes:
        [NSIndexSet indexSetWithIndex:row]
    columnIndexes:
        [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.myTable.numberOfColumns)]
    ];
    

提交回复
热议问题