我正在使用SwiftyJSON調用一些API並獲取一些數據。 當我使用:如果讓變量 - 使用未解決的標識符
if let variable = json["response"]["fieldname"] {
} else {
println("error")
}
我不能夠稍後使用可變的,例如爲值追加到一個數組。 例如:
if let variable1 = json["response"]["fieldname1"] {
} else {
println("error")
}
if let variable2 = json["response"]["fieldname2"] {
} else {
println("error")
}
var currentRecord = structure(variable1, variable2) ---> This line returns an error (use of unresolved identifier variable1) as not able to find variable1 or variable2
myArray.append(currentRecord)
我怎樣才能解決這個問題?
謝謝,我將使用Swift 1的解決方案。即使我認爲我不高興做到這一點,因爲有些變量可能需要爲空 – MeV