我一直在表达式列表中得到“期望的表达式”和期望的')''}'。我如何解决此问题。我试图通过除去方括号来解决它,但仍然无法正常工作。 导入UIKit 导入Firebase 进口FirebaseDatabase
class SearchViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var postData = [String]()
var ref: DatabaseReference!
var databaseHandle: DatabaseHandle?
override func viewDidLoad() {
super.viewDidLoad()
//let db = Firestore.firestore()
// Do any additional setup after loading the view.
ref = Database.database().reference()
databaseHandle = ref?.child("users").observe(DataEventType .childAdded, with: {
(snapshot) in
// code to execute when child added under users
let post = snapshot.value as? String
if let actualPost = post {
self.postData.append(actualPost)
self.tableView.reloadData()
) "expected expression"
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
)}
}
答案 0 :(得分:0)
您的支架外壳已关闭。 确保正确合上所有支架。
databaseHandle = ref?.child("users").observe(DataEventType .childAdded, with: {
(snapshot) in
// code to execute when child added under users
let post = snapshot.value as? String
if let actualPost = post {
self.postData.append(actualPost)
self.tableView.reloadData()
) "expected expression"
}}