Why is my code not displaying the string value attached to an integer? <p>I'm totally new to programming and Swift is the first language I'm learning.</p> <p>I've been researching this issue, but I'm not really sure I'm researching the right thing. Until now all my research has been about converting integers to strings etc, but I suspect that I'm barking up the wrong tree. And perhaps my question title is misleading too, but here's my scenario.</p> <p>I am working on a quiz app that stores all the questions and answers in a .json file in the following format:</p> <pre><code>{ "id" : "1", "question": "Earth is a:", "answers": [ "Planet", "Meteor", "Star", "Asteroid" ], "difficulty": "1" } </code></pre> <p>The correct answer is <strong>always</strong> the one listed first within the .json file.</p> <p>The app presents the question with the four possible answer buttons (which have been shuffled using the following code):</p> <pre><code> func loadQuestions(index : Int) { let entry : NSDictionary = allEntries.objectAtIndex(index) as! NSDictionary let question : NSString = entry.objectForKey("question") as! NSString let arr : NSMutableArray = entry.objectForKey("answers") as! NSMutableArray //println(question) //println(arr) labelQuestion.text = question as String let indices : [Int] = [0,1,2,3] //let newSequence = shuffle(indices) let newSequence = indices.shuffle() var i : Int = 0 for(i = 0; i &lt; newSequence.count; i++) { let index = newSequence[i] if(index == 0) { // we need to store the correct answer index currentCorrectAnswerIndex = i } let answer = arr.objectAtIndex(index) as! NSString switch(i) { case 0: buttonA.setTitle(answer as String, forState: UIControlState.Normal) break; case 1: buttonB.setTitle(answer as String, forState: UIControlState.Normal) break; case 2: buttonC.setTitle(answer as String, forState: UIControlState.Normal) break; case 3: buttonD.setTitle(answer as String, forState: UIControlState.Normal) break; default: break; } } </code></pre> <p>Once a button is pressed, the app checks the answer chosen with the following code:</p> <pre><code>func checkAnswer( answerNumber : Int) { if(answerNumber == currentCorrectAnswerIndex) { // we have the correct answer labelFeedback.text = "Correct!" labelFeedback.textColor = UIColor.greenColor() score = score + 1 labelScore.text = "Score: \(score)" totalquestionsasked = totalquestionsasked + 1 labelTotalQuestionsAsked.text = "out of \(totalquestionsasked)" accumulatedquestionsasked = accumulatedquestionsasked + 1 percentagecorrect = score / totalquestionsasked SaveScore() SaveBestScore() // later we want to play a "correct" sound effect PlaySoundCorrect() } else { // we have the wrong answer labelFeedback.text = "Wrong!" labelFeedback.textColor = UIColor.blackColor() totalquestionsasked = totalquestionsasked + 1 labelTotalQuestionsAsked.text = "out of \(totalquestionsasked)" accumulatedquestionsasked = accumulatedquestionsasked + 1 SaveScore() SaveBestScore() // we want to play a "incorrect" sound effect PlaySoundWrong() } } </code></pre> <p>So, what I'd like to do is change the labelQuestion text to present the correct answer if the user was wrong. </p> <p>I've tried a few options as follows:</p> <pre><code>labelQuestion.text = "The correct answer was: \(currentCorrectAnswerIndex)" </code></pre> <p>and</p> <pre><code>labelQuestion.text = "The correct answer was: \(currentCorrectAnswerIndex)" as string </code></pre> <p>and</p> <pre><code>let answertext = String(currentCorrectAnswerIndex) labelQuestion.text = "The correct answer was: \(answertext)" </code></pre> <p>All of these attempts have the same outcome - they provide the integer value corresponding to the button with the correct answer. For example, the user is presented with a message like:</p> <p><em>The correct answer was: 2</em> <strong>instead of</strong> <em>The correct answer was: Planet</em></p> <p>I know I must be making a newbie mistake, but any direction would be much appreciated. I'm using the latest version of Xcode / Swift.</p>