Hello,
I’m trying to enumerate the methods of a class in Swift using the
Objective-C runtime. Everything is working fine so far, except for the very
last step. Suppose I have a Swift class like this:
class Foo: SomeSuperclass {
@objc func bar() {
print("Hello, World!")
}
}
Using the Objective-C runtime methods, I can get the method with
class_copyMethodList and then get to the method’s implementation using
method_getImplementation. However, what I need to do next is to stick this into
a tuple that looks like this:
typealias FooEntry = (fooClass: SomeSuperclass.Type, methods: [(String, (Foo)
throws -> Void)])
For now, the workaround is to make a static variable that returns all
of the entries:
static var allEntries = {
return [
("bar", bar),
]
}
Is there any way to go from the raw IMP that I get back from the
runtime to the Swift type so I can construct this list dynamically?
Jeff Kelley
[email protected] | @SlaunchaMan <https://twitter.com/SlaunchaMan> |
jeffkelley.org <http://jeffkelley.org/>
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users