Karpisdiem Karpisdiem - 3 months ago 50
iOS Question

Multidimensional Array output to label

Hi I'm having problems printing it to the label which is the output.text, it keeps coming out blank, but when I print to console it shows the number.

name.state = stateText.text

var stateName = [
["AK - Alaska", tax.alaska!],
["AL - Alabama", tax.alabama!],
["AR - Arkansas", tax.arkansas!],
["AZ - Arizona", tax.arizona!],
["CA - California", tax.california!]

for var i = 0; i < stateName.count; i++ {
if tax.state == stateName[i][0] {
stateName[i][1] = Double(taxNumb.text!)!
output.text = stateName[i][1] as? String


Don't cast to String. What you have is a Double, that is not just castable to String.
You need to create a String:

output.text = String(stateName[0][1])


output.text = "\(stateName[i][1])"