2019-07-28 17:08:10 +08:00
|
|
|
//
|
|
|
|
// NSTableView+Reload.swift
|
|
|
|
// ClashX
|
|
|
|
//
|
2019-10-02 21:43:18 +08:00
|
|
|
// Created by yicheng on 2019/7/28.
|
2019-07-28 17:08:10 +08:00
|
|
|
// Copyright © 2019 west2online. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
extension NSTableView {
|
|
|
|
func reloadDataKeepingSelection() {
|
|
|
|
let selectedRowIndexes = self.selectedRowIndexes
|
2019-10-20 13:40:50 +08:00
|
|
|
reloadData()
|
2019-07-30 14:21:36 +08:00
|
|
|
var indexs = IndexSet()
|
|
|
|
for index in selectedRowIndexes {
|
2019-10-20 13:40:50 +08:00
|
|
|
if index >= 0 && index <= numberOfRows {
|
2019-07-30 14:21:36 +08:00
|
|
|
indexs.insert(index)
|
|
|
|
}
|
|
|
|
}
|
2019-10-20 13:40:50 +08:00
|
|
|
selectRowIndexes(indexs, byExtendingSelection: false)
|
2019-07-28 17:08:10 +08:00
|
|
|
}
|
|
|
|
}
|