diff options
author | Roopesh Chander <roop@roopc.net> | 2019-01-02 01:07:46 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2019-01-14 14:52:30 +0530 |
commit | 7934d6b0c798924c859a4b0d55f6561d48f6eaff (patch) | |
tree | 31ef34d4b653629eb6abfd79a8663fea3e6eda64 /WireGuard/WireGuard/UI/macOS/NSTableView+Reuse.swift | |
parent | macOS: Capitalize All Rights Reserved (diff) | |
download | wireguard-apple-7934d6b0c798924c859a4b0d55f6561d48f6eaff.tar.xz wireguard-apple-7934d6b0c798924c859a4b0d55f6561d48f6eaff.zip |
macOS: Manage tunnels window: Tunnels list
Signed-off-by: Roopesh Chander <roop@roopc.net>
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 + } +} |