IPhone : How to convert a String into a Function call in Swift

on Saturday, April 18, 2015

I am writing a little app which I would like to use as a calculator. For the operators of the calculator I started with a switch statement to e.g. multiply two values. Therefore I created a dictionary and it worked fine.


I now found it would be quite useful and code saving if I'd write something like "number1 operationButton.currentTitle number2", where "operationButton.currentTitle" would represent "+", "-", "*" or "/".


My question now is how can I convert the string of "operationButton.currentTitle" into a function call for these operators?


0 comments:

Post a Comment