【发布时间】:2017-01-31 17:58:11
【问题描述】:
我正在尝试使用循环在我的 iOS Firebase 数据库中填充一些数据,但它似乎只保存了最后一个值。有点难过:/
while (counter < 50){
patientName = newPatient.patientName + String(counter)
FIRDatabase.database().reference().child("testTable").child("patient").setValue(patientName)
FIRDatabase.database().reference().child("testTable").child("patient").child(patientName).child("patient DOB").setValue(newPatient.patientDOB)
FIRDatabase.database().reference().child("testTable").child("patient").child(patientName).child("test var").setValue(newPatient.patienttest)
FIRDatabase.database().reference().child("testTable").child("patient").child(patientName).child("test var 1").setValue(newPatient.patienttest1)
counter += 1
}
这是我在控制台上看到的输出:
2017-01-31 09:48:25.999233 DemoTest[15969:1332318] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2017-01-31 09:48:25.999827 DemoTest[15969:1332318] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
数据库只是添加/保存最后一个值:
【问题讨论】:
标签: ios firebase swift3 firebase-realtime-database