Spartanu13 Spartanu13 - 5 months ago 55
Swift Question

Initialization of variable was never used

enter image description here

I am new to Swift. I am trying to do a little project. I got this warning on

var
:

Initialization of variable was never used consider replacing with assignment to '_' or removing it.


If anyone could help me, thank you in advance :)

Answer

If you plan to use this variables later - just ignore this warnings.

But didn't you mean something like this?

var allText = ""
var firstLetter = ""
var firstSentence = ""
var body = ""
var info = ""
var map = ""
var about = ""

func changeNameToIndex(index: Int) {
    switch index {
    case 0:
        allText = "..."
        firstLetter = "..."
        // etc
    case 1:
        allText = "..."
        firstLetter = "..."
        // etc
    case 2:
    // ....
    default:
    // ....
    }
}