Skip to content

Instantly share code, notes, and snippets.

@shalom-aviv
Created July 6, 2022 10:12
Show Gist options
  • Save shalom-aviv/ccfef368b835ae21d8baf60c74677726 to your computer and use it in GitHub Desktop.
Save shalom-aviv/ccfef368b835ae21d8baf60c74677726 to your computer and use it in GitHub Desktop.
extension NSObject {
var getAllSelectors: [Selector] {
var methodCount: UInt32 = 0
guard
let methodList = class_copyMethodList(type(of: self), &methodCount),
methodCount != 0
else {
return []
}
return (0 ..< Int(methodCount))
.compactMap { method_getName(methodList[$0]) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment