Created
March 2, 2023 10:19
Revisions
-
ncreated created this gist
Mar 2, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ extension NSObject { var __methods: [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]) }) } var __properties: Any { var propertiesCount: UInt32 = 0 guard let propertiesList = class_copyPropertyList(type(of: self), &propertiesCount), propertiesCount != 0 else { return [] } return (0 ..< Int(propertiesCount)) .compactMap({ property_getName(propertiesList[$0]) }) .map({ NSString(cString: $0, encoding: NSUTF8StringEncoding) }) } }