If I have functions in a Swift class like:
class MyClass: NSObject {
class func drawingOne(frame: CGRect) {}
class func drawingTwo(frame: CGRect) {}
}
Note, I can not edit the code in the above class. It is provided by a third party.
How can I pick a function matching a string? For example:
let function = function(forName: "drawingOne")
to give the function:
drawingOne
So, I could do something like:
guard let drawFunction = function(forName: "drawingOne")
else { return }
if let drawFunction = drawFunction as? ((CGRect) -> Void) {
drawFunction(frame: bounds)
}