Use shallow search to improve performance

This commit is contained in:
Pete Schaffner
2024-02-07 21:39:36 +01:00
parent bc946109b7
commit 591c05641b
2 changed files with 9 additions and 21 deletions

View File

@@ -1,17 +1,6 @@
import AppKit
extension NSView {
func firstSubview(withClassName name: String) -> NSView? {
for subview in subviews {
if String(describing: type(of: subview)) == name {
return subview
} else if let found = subview.firstSubview(withClassName: name) {
return found
}
}
return nil
}
func subviews(withClassName name: String) -> [NSView] {
var result = [NSView]()