Skip to content

Commit 2ce2662

Browse files
author
Stanislas Chevallier
committed
Cleanup up some warnings
1 parent 3df37db commit 2ce2662

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Subtitler/Extensions/NSView+SY.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import Cocoa
99

1010
// https://stackoverflow.com/a/54310657/1439489
1111
extension NSView {
12-
func bringSubviewToFront(_ view: NSView) {
13-
var theView = view
14-
self.sortSubviews({(viewA,viewB,rawPointer) in
15-
let view = rawPointer?.load(as: NSView.self)
16-
17-
switch view {
18-
case viewA:
12+
func bringSubviewToFront(_ subview: NSView) {
13+
self.sortSubviews({ (viewA, viewB, subviewID) in
14+
if viewA.uniqueID == subviewID {
1915
return ComparisonResult.orderedDescending
20-
case viewB:
16+
}
17+
if viewB.uniqueID == subviewID {
2118
return ComparisonResult.orderedAscending
22-
default:
23-
return ComparisonResult.orderedSame
2419
}
25-
}, context: &theView)
20+
return ComparisonResult.orderedSame
21+
}, context: subview.uniqueID)
22+
}
23+
24+
private var uniqueID: UnsafeMutableRawPointer {
25+
return Unmanaged.passUnretained(self).toOpaque()
2626
}
2727
}

0 commit comments

Comments
 (0)