Add comments/docs and make method name clearer

This commit is contained in:
Pete Schaffner
2024-02-07 21:44:44 +01:00
parent 591c05641b
commit 93fb852d9b
2 changed files with 7 additions and 4 deletions

View File

@@ -1,8 +1,8 @@
import AppKit
extension NSView {
func subviews(withClassName name: String) -> [NSView] {
/// Recursively finds and returns descendant views that have the given class name.
func descendants(withClassName name: String) -> [NSView] {
var result = [NSView]()
for subview in subviews {
@@ -10,7 +10,7 @@ extension NSView {
result.append(subview)
}
result += subview.subviews(withClassName: name)
result += subview.descendants(withClassName: name)
}
return result