Karpisdiem Karpisdiem - 1 year ago 100
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

Answer Source

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])"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download