Is it possible to have a tableView which has ex. five (5) rows denoting users in a group.
The table is setup for swipe to delete users. The admin of the group can delete any and/or all users in the table but he cannot delete himself since he is the admin.
So what I'm looking for is not allow the swipe action on his index on the table but allow it for everyone else in the tableview.
Currently it returns everything with UITableViewCellEditingStyle = .none since its initialized with .none
and the return value is executed prior to the firebase read is completed.
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
var cellStyleForEditing: UITableViewCellEditingStyle = .none
poolRef = Database.database().reference(withPath: "Pools")
poolRef.child(self.poolID).child("PoolAdmin").observeSingleEvent(of: .value, with: { snapshot in
if (snapshot.value as! String == self.players[indexPath.row]) {
print("Is Admin")
cellStyleForEditing = .none
} else {
print("Not Admin")
cellStyleForEditing = .delete
}
}) { (error) in
print(error.localizedDescription)
}
//
return cellStyleForEditing
}