How to change a buttons name through string in Swift?
<p>For my first app I am making a game in which the player can change the difficulty. When he choose a difficulty, some values must be changed.</p>

<p>One of this values is "maxDynamites" and I am using 2 difficulties, easy and normal. On easy, the value is 3 and on normal mode the value is 1.</p>

<p>Now, I have declared it as followed:</p>

<pre><code>func setDifficulty()
{
    if Difficulty == 0
    {
        maxDynamites = dif0MaxDynamites
        else if Difficulty == 1
        {
            maxDynamites = dif1MaxDynamites
        }
    }
}
</code></pre>

<p>This will do the trick, but I am planning for a lot more variables to use and more difficulties. Is there a way I can remove the dif0MaxDynamites and change it to something that will automatically change the "0" to a "1" if the difficulty is set to normal? I don't think using if's all the time is correct, and in this way I must copy paste my code for the amount of difficulties... Any help is welcome.</p>