aboutsummaryrefslogblamecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/NSTableView+Reuse.swift
blob: 979b123af6b730ca734f7dd8b0ba000216d21728 (plain) (tree)
1
2
                               
                                                             














                                                                                 
// SPDX-License-Identifier: MIT
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.

import Cocoa

extension NSTableView {
    func dequeueReusableCell<T: NSView>() -> T {
        let identifier = NSUserInterfaceItemIdentifier(NSStringFromClass(T.self))
        if let cellView = makeView(withIdentifier: identifier, owner: self) {
            //swiftlint:disable:next force_cast
            return cellView as! T
        }
        let cellView = T()
        cellView.identifier = identifier
        return cellView
    }
}