Skip to content

Instantly share code, notes, and snippets.

@mutablestudio
Last active February 14, 2017 12:41
Show Gist options
  • Save mutablestudio/ad2cd90af0390af52a70f6e7d4686d31 to your computer and use it in GitHub Desktop.
Save mutablestudio/ad2cd90af0390af52a70f6e7d4686d31 to your computer and use it in GitHub Desktop.
swift 3 perform selector with argument
//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