Dynamically call a function in Swift
问题 I’m trying to implement a router pattern in Swift and can’t figure out how to dynamically call a method. For example, there’s an array of arguments: let arguments: [Any] = [100, 0.5, "Test"] And a handler which needs to be called: public class MyClass { public func handler(value1: Int, value2: Double, text: String) { print("int=\(value1), double=\(value2), string=\(text)") } } let myClass = MyClass() The router has an untyped function reference which it will use as a callback: let callback: