I’m attempting to delete a desk view cell in swift and once I delete the cell I additionally have to delete the info in firebase. So I take advantage of Database.database().baby("tweet")
that is the place the error is it says can not fin Database in scope.
import UIKit
import Firebase
import Firestore
class TableViewController: UITableViewController {
var db:Firestore!
var tweetArray = [tweet]()
override func viewDidLoad() {
tremendous.viewDidLoad()
tableView.allowsMultipleSelectionDuringEditing = true
db = Firestore.firestore()
loadData()
checkForUpdates()
}
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
Database.database().baby("tweet") "Error can not discover Database in scope"
}
func loadData() {
db.assortment("tweet").getDocuments() {
querySnapshot, error in
if let error = error {
print("(error.localizedDescription)")
}else{
self.tweetArray = querySnapshot!.paperwork.compactMap({tweet(dictionary: $0.information())})
DispatchQueue.most important.async {
self.tableView.reloadData()
}
}
}
}
func checkForUpdates() {
db.assortment("tweet").whereField("timeStamp", isGreaterThan: Date())
.addSnapshotListener {
querySnapshot, error in
guard let snapshots = querySnapshot else {return}
snapshots.documentChanges.forEach {
diff in
if diff.sort == .added {
self.tweetArray.append(tweet(dictionary: diff.doc.information())!)
DispatchQueue.most important.async {
self.tableView.reloadData()
}
}
}
}
}
@IBAction func composeSweet(_ sender: Any) {
let composeAlert = UIAlertController(title: "Add Worker", message: "Add Worker", preferredStyle: .alert)
composeAlert.addTextField { (textField:UITextField) in
textField.placeholder = "Identify"
}
composeAlert.addTextField { (textField:UITextField) in
textField.placeholder = "Adress"
}
composeAlert.addAction(UIAlertAction(title: "Cancel", type: .cancel, handler: nil))
composeAlert.addAction(UIAlertAction(title: "Add Worker", type: .default, handler: { (motion:UIAlertAction) in
if let identify = composeAlert.textFields?.first?.textual content,
let content material = composeAlert.textFields?.final?.textual content {
let newTweet = tweet(identify: identify, content material: content material,timeStamp: Date())
var ref:DocumentReference? = nil
ref = self.db.assortment("tweet").addDocument(information: newTweet.dictionary) {
error in
if let error = error {
print("Error including doc: (error.localizedDescription)")
}else{
print("Doc added with ID: (ref!.documentID)")
}
}
}
}))
self.current(composeAlert, animated: true, completion: nil)
}
// MARK: - Desk view information supply
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
return tweetArray.depend
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let tweet1 = tweetArray[indexPath.row]
cell.textLabel?.textual content = "(tweet1.identify) (tweet1.content material)"
cell .detailTextLabel?.textual content = "(tweet1.timeStamp) "
return cell
}
}
I attempted importing completely different firebase imports and that did not work i am unsure if it has one thing to do with my cocoa pods. these are the cocapods I’ve downloaded: pod ‘Firebase/Core
pod ‘Firebase/Auth’ pod ‘Firestore’