Last active
September 10, 2018 02:49
-
-
Save velyan/c60d423ead3e5911098cea0ea9e3b1ee to your computer and use it in GitHub Desktop.
NSObject Introspection
This file contains 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 characters
import Foundation | |
var count: UInt32 = 0 | |
let list = class_copyMethodList(NSObject.self, &count) | |
var result: Set<String> = Set() | |
for i in 0 ..< count { | |
let x = list![Int(i)] | |
let nameString = NSStringFromSelector(method_getName(x)) | |
if !(nameString.hasPrefix("_") || nameString.hasSuffix(":") || nameString.hasSuffix("_")) { | |
result.insert(nameString) | |
} | |
} | |
let list2 = class_copyPropertyList(NSObject.self, &count) | |
for i in 0 ..< count { | |
let x = list2![Int(i)] | |
let nameString = String(cString: property_getName(x)) | |
result.insert(nameString) | |
} | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment