Last active
February 14, 2017 12:41
-
-
Save mutablestudio/ad2cd90af0390af52a70f6e7d4686d31 to your computer and use it in GitHub Desktop.
swift 3 perform selector with argument
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
//if you have a dictionary object passed in, and one element is the function name you can do the following | |
//inbound 'params' as [String: Any] | |
let funcName = String(format: "%@:", (params["function"] as? String)!) //note the ':' for single parameter method | |
let selector = NSSelectorFromString(funcName) | |
self.perform(selector, with: params) | |
func getSomeData(_ params: [String: Any]) { | |
print(params) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment