diff options
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/NSTableView+Reuse.swift | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/NSTableView+Reuse.swift b/WireGuard/WireGuard/UI/macOS/NSTableView+Reuse.swift new file mode 100644 index 0000000..3a36b6a --- /dev/null +++ b/WireGuard/WireGuard/UI/macOS/NSTableView+Reuse.swift @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018 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 + } +} |