0
我無法訪問常量或它們例如函數中定義的變量我已經定義了一個常數didselectrow
函數內部現在,當我選擇一行常量的值獲得印在控制檯,但現在我想保存firebase
該值,所以當我在button
稱之爲價值是不確定的,爲什麼?我該怎麼做?
訪問常量或函數裏面的變量保存在火力迅速3
這裏是我寫在button
不斷countryGroup
是不確定的代碼。因爲我已經在didselectrow
按鈕
@IBAction func createAccountAction(_ sender: Any) {
ref.child("user_registration").child(UserID!).setValue(["username": fullName.text, "email": emailTextField.text, "contact": numberText.text, "city": myCity.text, "state": countryText.text, "country": country])
}
didselectrow定義它
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView == tableViewB {
let selectedData = dropDownList[indexPath.row]
buttonB.setTitle(selectedData, for: .normal)
self.tableViewB.isHidden = true
self.flag = 1
let indexPath = tableViewB.indexPathForSelectedRow
let currentCell = tableViewB.cellForRow(at: indexPath!)! as UITableViewCell
let country = currentCell.textLabel!.text!
print("\(country)")
}
,因爲它變成了局部變量而不是實例變量。定義變量外的函數。 –
我應該怎麼做才能在Firebase中檢索? –
聲明讓selectedData:Int?外表函數和內功能只是用 - :selectedData = DROPDOWNLIST [indexPath.row] –