fetch the last document from Firestore collection - swift

I have a tableViewController that fetch document from Firestore collection which called "paperHole" and i have refreshControl which is a UIrefreshControl that refresh the tableView but in this refreshControl action i want to fetch the last document only that recorded in the Firestore . what i mean is if the collection "paperHole" have 3 documents which is ( A, B, C ) and the last document recorded in this collection is C , i want to fetch the document C only .
i tried with limit(toLast: 1) but it didn't work for me
import UIKit
import FirebaseFirestore
import Firebase
import FirebaseAuth
import UserNotifications
class OrderTableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {
#IBOutlet var order5: UITableView!
struct GlobalVariable{
static var myString = String()
}
var db: Firestore!
var street = [String]()
var firstName = [String]()
var lastName = [String]()
var blockNumber = [String]()
var phone = [String]()
var reciept = [String]()
var houseNumber = [String]()
var price = [String]()
var amount = [String]()
var block = [String]()
var Area = [String]()
var names = [String]()
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
refreshControl.attributedTitle = NSAttributedString(string: "")
refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
order5.addSubview(refreshControl)
order5.separatorStyle = .none
order5.dataSource = self
order5.delegate = self
db = Firestore.firestore()
}
#objc func refresh(_ sender: AnyObject) {
loadData1Refresh()
}
func loadData1Refresh() {
Firestore.firestore().collection("paperHole").limit(toLast: 1).getDocuments() {
(querySnapshot, err) in
if let err = err
{
print("Error getting documents: \(err)");
}
else
{
var count = 0
for document in querySnapshot!.documents {
count += 1
print("\(document.documentID) => \(document.data())");
self.firstName.append(document.get("firstname") as? String ?? "")
self.lastName.append(document.get("lastname") as? String ?? "")
self.street.append(document.get("street") as? String ?? "")
self.blockNumber.append(document.get("blockNumber") as? String ?? "")
self.Area.append(document.get("area") as? String ?? "")
self.phone.append(document.get("phone") as? String ?? "")
self.reciept.append(document.get("reciept") as? String ?? "")
self.houseNumber.append(document.get("houseNumber") as? String ?? "")
self.price.append(document.get("total price") as? String ?? "")
self.amount.append(document.get("amount") as? String ?? "")
}
}
self.order5.reloadData()
}
}

I believe that using limit won't work unless you specify an order too.
Firstly, you'll need to attach a date to your paperHole object. As per the Firebase Docs:
Important: Unlike "push IDs" in the Firebase Realtime Database, Cloud Firestore auto-generated IDs do not provide any automatic ordering. If you want to be able to order your documents by creation date, you should store a timestamp as a field in the documents.
Then you can query your data using:
Firestore.firestore().collection("paperHole").order(by: "date", descending: true).limit(to: 1)

Related

Displaying Username in Swift and FireBase

I'm trying to display the users username that stored in firebase. I'm not sure if Im saving the username correctly or if that's even the problem. I can't seem to access the data or display it at all. Any tips? I have a screenshot of the Cloud Firestore attached.
SignupViewController
import UIKit
import FirebaseAuth
import Firebase
import AVKit
import FirebaseFirestore
class SignUpViewController: UIViewController {
var videoPlayer:AVPlayer?
var videoPlayerLayer:AVPlayerLayer?
#IBOutlet weak var firstNameTextField: UITextField!
#IBOutlet weak var lastNameTextField: UITextField!
#IBOutlet weak var emailTextField: UITextField!
#IBOutlet weak var passwordTextField: UITextField!
#IBOutlet weak var BackButton: UIButton!
#IBOutlet weak var UserNameTextField: UITextField!
#IBOutlet weak var signUpButton: UIButton!
#IBOutlet weak var errorLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let tap = UITapGestureRecognizer(target: view, action: #selector(UIView.endEditing))
view.addGestureRecognizer(tap)
// Do any additional setup after loading the view.
setupElements()
}
func setupElements(){
//hides the error label
errorLabel.alpha = 0
//styles the text and buttons
Utilities.styleTextField(UserNameTextField)
Utilities.styleTextField(firstNameTextField)
Utilities.styleTextField(lastNameTextField)
Utilities.styleTextField(passwordTextField)
Utilities.styleTextField(emailTextField)
Utilities.styleFilledButton(signUpButton)
}
/*
// MARK: - 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.
}
*/
// this function makes sure all data is good
func validateFields() -> String?
{
//make sure fields are filled
if firstNameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || lastNameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || emailTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || UserNameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == ""
{
return "Please fill all fields"
}
let cleanPassword = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
if Utilities.isPasswordValid(cleanPassword) == false{
return "Needs 8 charaters, number, and special charater"
}
return nil
}
#IBAction func signUpTapped(_ sender: Any) {
//validate fields
let error = validateFields()
if error != nil{
showError(error!)
}
else{
let firstName = firstNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let lastName = lastNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
let username = UserNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
//create user
Auth.auth().createUser(withEmail: email, password: password) { result, err in
if err != nil{
self.showError("Error creating user")
}
else
{
//User is stored sucessfully, store the first and last name
let database = Firestore.firestore()
database.collection("UserInfo").addDocument(data: ["firstname": firstName,"email": email, "lastname": lastName, "username": username, "uid": result!.user.uid]) {(error) in
if error != nil
{
self.showError("First name and last name couldnt be saved.")
}
}
self.transitionToHome()
}
}
}
}
func showError(_ message:String){
errorLabel.text = message
errorLabel.alpha = 1
}
func transitionToHome(){
let homeViewController = storyboard?.instantiateViewController(identifier: Constants.StoryBoard.homeViewController) as?
HomeViewController
view.window?.rootViewController = homeViewController
view.window?.makeKeyAndVisible()
}
override func viewWillAppear(_ animated: Bool) {
//Set up video in background
setUpVideo()
}
func setUpVideo(){
//Get path to resource bundle
let bundlePath = Bundle.main.path(forResource: "IMG_7211 2", ofType: "mov")
guard bundlePath != nil else{
return
}
//create the url from it
let url = URL(fileURLWithPath: bundlePath!)
//Create The video Player item
let item = AVPlayerItem(url: url)
//create the player
videoPlayer = AVPlayer(playerItem: item)
//create the layer
videoPlayerLayer = AVPlayerLayer(player: videoPlayer!)
//adjust the size and frame
videoPlayerLayer?.frame = CGRect(x: -self.view.frame.size.width*1.5, y:0, width: self.view.frame.size.width*4, height: self.view.frame.size.height)
view.layer.insertSublayer(videoPlayerLayer!, at: 0)
//add and play
videoPlayer?.playImmediately(atRate: 0.8)
}
}
CurrentUser.swift
import Foundation
struct CurrentUser{
let uid: String
let name: String
let email: String
let profilepictureURL:String
init(uid: String, dictionary: [String: Any]){
self.uid = uid
self.name = dictionary["username"] as? String ?? ""
self.email = dictionary["email"] as? String ?? ""
self.profilepictureURL = dictionary["profilepictureURL"] as? String ?? ""
}
}
ProfileViewController
import UIKit
import Firebase
import FirebaseAuth
import FirebaseInstallations
import FirebaseFirestore
import FirebaseStorage
import FirebaseDatabase
class ProfileViewController: UIViewController {
#IBOutlet weak var SignOut: UIButton!
#IBOutlet weak var UserName: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
UserNameLabel()
// Do any additional setup after loading the view.
}
func UserNameLabel()
{
if Auth.auth().currentUser != nil
{
guard let uid = Auth.auth().currentUser?.uid else {return}
Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value) { (snapshot) in
guard let dict = snapshot.value as? [String: Any] else {return}
let user = CurrentUser(uid: uid, dictionary: dict)
self.UserName.text = user.username
}
}
}
#IBAction func SignOut(_ sender: Any) {
if Auth.auth().currentUser != nil {
do {
try Auth.auth().signOut()
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Vc")
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true, completion: nil)
}
catch let error as NSError {
print(error.localizedDescription)
}
}
}
}
The problem is you are saving the data to Firebase Firestore, and then trying to access it from firebase real time database. Firebase Realtime Database and Firebase Firestore are 2 completely different backend servers and you are trying to use both at the same time. You need to pick only 1 and stick with it.
You are saving it to firebase firestore by using:
let database = Firestore.firestore()
database.collection("UserInfo").addDocument()
then after you save it to firestore you are trying to access it from real time database, not Firestore which is causing it to return nil:
Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value) { (snapshot) in
So instead what you need to do is get it back from firestore by using this:
Firestore.firestore().collection("s").getDocuments { query, error in
for doc in query!.documents {
// Successfully retrieved data from firestore.
}
}
Note: You could also instead save it to the real time database instead of firestore, but it just depends which one will work better for your app. You need to pick either Firestore or the Database, you can't use both. Here is more info to help you decide which one is better. More Info

get document from multi collection for each user firebase swift

Im trying to get document from firestore collection for each user , for example let say if user logged in with this email "Hola#example.com" , i want to get document from collection named "Hola" , and if user logged in with this email "Hi#example.com" i want to get document from "Hi" collection i tried this code but it didn't work fine .
import UIKit
import FirebaseFirestore
import Firebase
class orderTableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {
#IBOutlet var order: UITableView!
var db: Firestore!
var firstName = [String]()
var lastName = [String]()
override func viewDidLoad() {
super.viewDidLoad()
db = Firestore.firestore()
let v = logInViewController()
if v.userNameField?.text == “Hi#example.com” {
loadData1()
}
if v.userNameField?.text == “Hola#example.com” {
loadData2()
}
}
func loadData1() {
db.collection(“Hi”).getDocuments()
{
(querySnapshot, err) in
if let err = err
{
print("Error getting documents: \(err)");
}
else
{
var count = 0
for document in querySnapshot!.documents {
count += 1
print("\(document.documentID) => \(document.data())");
self.firstName.append(document.get("firstname") as? String ?? "")
self.lastName.append(document.get("lastname") as? String ?? "")
}
}
self.order.reloadData()
}
}
func loadData2() {
db.collection(“Hola”).getDocuments()
{
(querySnapshot, err) in
if let err = err
{
print("Error getting documents: \(err)");
}
else
{
var count = 0
for document in querySnapshot!.documents {
count += 1
print("\(document.documentID) => \(document.data())");
self.firstName.append(document.get("firstname") as? String ?? "")
self.lastName.append(document.get("lastname") as? String ?? "")
}
}
self.order.reloadData()
}
}
is there a simple way to achieve it ?
You can use Firebase auth with the currentUser property.
let user = Auth.auth().currentUser
let email = user.email
then use this email to grab their collection:
db.collection(email).getDocuments()
read more about this here

Why is my Firestore data not displaying as table view?

I am currently working on a project with Xcode (User Interface: Storyboard) and Google Firebase. I cannot get my app to display the information like this:
Desired output
The way I got this picture was by starting a test project selecting SwiftUI as my User Interface, and only having ONE single view controller. In my app a user will only arrive to this page after they have logged in and click a button that takes them to the table view.
My app currently prints the result at the bottom of Xcode:
Current output
import UIKit
import FirebaseFirestore
class AssetViewController: UIViewController {
#IBOutlet weak var assetList: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let db = Firestore.firestore()
db.collection("assets").getDocuments { (snapshot, error) in
if error != nil {
print("error")
} else {
for document in (snapshot?.documents)! {
if let brand = document.data() ["brand"] as? String {
if let description = document.data() ["description"] as? String {
if let date = document.data() ["date"] as? String {
if let cost = document.data() ["cost"] as? String {
if let serial = document.data() ["serial"] as? String {
if let warranty = document.data() ["warranty"] as? String {
if let warranty_cost = document.data() ["warranty_cost"] as? String {
print("\(document.documentID) => \(document.data())") }
}
}
}
}
}
}
}
}
}
}
}
I have the following class:
import Foundation
import FirebaseFirestore
class AssetsViewModel: ObservableObject {
#Published var assets = [Asset] ()
private var db = Firestore.firestore()
func fetchData() {
db.collection("assets").addSnapshotListener { (QuerySnapshot, error) in
guard let documents = QuerySnapshot?.documents else {
print("No assets in here")
return
}
self.assets = documents.map { (QueryDocumentSnapshot) -> Asset in
let data = QueryDocumentSnapshot.data()
let brand = data["brand"] as? String ?? ""
let description = data["description"] as? String ?? ""
let date = data["date"] as? String ?? ""
let cost = data["cost"] as? String ?? ""
let serial = data["serial"] as? String ?? ""
let warranty = data["warranty"] as? String ?? ""
let warranty_cost = data["warranty_cost"] as? String ?? ""
return Asset(brand: brand, description: description, date: date, cost: cost, serial: serial, warranty: warranty, warranty_cost: warranty_cost)
}
}
}
}
And I have the following structure:
import Foundation
struct Asset: Identifiable {
var id: String = UUID().uuidString
var brand: String
var description: String
var date: String
var cost: String
var serial: String
var warranty: String
var warranty_cost: String
}
My main goal is to display the information like the first picture. I would appreciate any help given.
This is the code that I used to display the first picture:
import SwiftUI
struct ContentView: View {
#ObservedObject private var viewModel = AssetsViewModel()
var body: some View {
NavigationView {
List(viewModel.assets) { asset in
VStack(alignment: .leading) {
Text(asset.brand)
.font(.headline)
Text(asset.description)
.font(.subheadline)
Text(asset.date)
.font(.subheadline)
Text(asset.cost)
.font(.subheadline)
Text(asset.serial)
.font(.subheadline)
Text(asset.warranty)
.font(.subheadline)
Text(asset.warranty_cost)
.font(.subheadline)
}
}
.navigationBarTitle("Assets")
.onAppear() {
self.viewModel.fetchData()
}
}
}
}
struct AssetViewSwiftUIView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The post below helped me. The error I was getting was because Swift did not like me naming the ViewTable "assetList". Once I changed the name to "tableView" and changed in the code, it worked well. I added extra code to make the cells auto adjust from here: why UITableViewAutomaticDimension not working?.
Thank you very much for your help!
You need something like this:
import Foundation
import UIKit
import FirebaseFirestore
class myTableCell: UITableViewCell {
#IBOutlet weak var brand: UILabel!
#IBOutlet weak var description: UILabel!
#IBOutlet weak var date: UILabel!
#IBOutlet weak var cost: UILabel!
#IBOutlet weak var serial: UILabel!
#IBOutlet weak var warranty: UILabel!
#IBOutlet weak var warrantyCost: UILabel!
}
class IndexAssets {
var brand = ""
var description = ""
var date = ""
var cost = ""
var serial = ""
var warranty = ""
var warrantyCost = ""
init(brand: String, description: String, date: String, cost: String, serial: String, warranty: String, warrantyCost: String)
{
self.brand = brand
self.description = description
self.date = date
self.cost = cost
self.serial = serial
self.warranty = warranty
self.warrantyCost = warrantyCost
}
}
class AssetViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
#IBOutlet weak var assetList: UITableView!
var dataArray: [IndexAssets] = [IndexAssets]()
override func viewDidLoad() {
super.viewDidLoad()
downloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! myTableCells
cell.brand?.text = dataArray[indexPath.row].brand
cell.description?.text = dataArray[indexPath.row].description
cell.date?.text = dataArray[indexPath.row].date
cell.cost?.text = dataArray[indexPath.row].cost
cell.serial?.text = dataArray[indexPath.row].serial
cell.warranty?.text = dataArray[indexPath.row].warranty
cell.warrantyCost?.text = dataArray[indexPath.row].warrantyCost
return cell
}
func downloadData()
{
let db = Firestore.firestore()
db.collection("assets").getDocuments { (snapshot, error) in
if error != nil
{
print("error")
}
else
{
for document in (snapshot?.documents)!
{
let brand = document.data() ["brand"] as? String
let description = document.data() ["description"] as? String
let date = document.data() ["date"] as? String
let cost = document.data() ["cost"] as? String
let serial = document.data() ["serial"] as? String
let warranty = document.data() ["warranty"] as? String
let warrantyCost = document.data() ["warranty_cost"] as? String
if let brand = brand, let description = description, let date = date, let cost = cost, let serial = serial, let warranty = warranty, let warrantyCost = warrantyCost
{
let insert = IndexAssets(brand: brand, description: description, date: date, cost: cost, serial: serial, warranty: warranty, warrantyCost: warrantyCost)
self.dataArray.append(insert)
}
}
self.assetList.reloadData()
}}
}
}
Also, remember in Storyboard to:
Assign "cell" to your Dynamic Cell identifier
Select myTableCell as Class for that cell
Drag labels from the class to connect them to storyboard
Drag your table to your View Controller (Yellow Icon on top) and select DataSource and Delegate.

Struggling to pass data to UI - Swift

Good day, I'm trying to pass data to my Profile UI View.
This is my Customer Class:
class Customer {
// Creating a customer
let name: String
let surname: String
let contactNo: String
let email: String
init(name: String,surname: String,contactNo: String,email: String) {
self.name = name
self.surname = surname
self.contactNo = contactNo
self.email = email
}
}
This is my code whereby I try to parse data from Firestore to display a customers details:
class ProfileCus: UIViewController {
// Labels to display data
#IBOutlet weak var nameLabel: UILabel!
#IBOutlet weak var surnameLabel: UILabel!
#IBOutlet weak var emailLabel: UILabel!
#IBOutlet weak var contactLabel: UILabel!
// Reference to customer collection in Firestore
private var customerRefCollection: CollectionReference!
// Customer Object
private var customer: Customer?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
customerRefCollection = Firestore.firestore().collection("customers")
nameLabel.text = customer?.name
surnameLabel.text = customer?.surname
emailLabel.text = customer?.email
contactLabel.text = customer?.contactNo
}
// This function notifies the view controller that the view is about to load so it is best to acquire the data in here before the view loads so that it will be ready to display.
override func viewWillAppear(_ animated: Bool) {
// Get the current user ID
let userID = Auth.auth().currentUser?.uid
// Locate the user information on Firestore
customerRefCollection.document(userID!).getDocument { (snapshot, error) in
if let err = error {
debugPrint("Error fetching documents: \(err)")
}
else {
// Ensure that if there's nothing in the document that the function returns
guard let snap = snapshot else {return}
// Parse the data to the customer model
let data = snap.data()
let name = data?["name"] as? String ?? ""
let surname = data?["surname"] as? String ?? ""
let email = data?["email"] as? String ?? ""
let contact = data?["contact no"] as? String ?? ""
// Create the customer and pass it to the global variable
let cus = Customer(name: name, surname: surname, contactNo: contact, email: email)
self.customer = cus
}
}
}
}
Everything on the Firestore side is working fine and I am able to read/retrieve data but I'm struggling to pass the data to my UI via my Customer Class. Using print statements it seems as if the customer object is nil.
Output once the code runs
func getDataFromFirebase(completion:#escaping() -> ()){
let userID = Auth.auth().currentUser?.uid
// Locate the user information on Firestore
customerRefCollection.document(userID!).getDocument { (snapshot, error) in
if let err = error {
debugPrint("Error fetching documents: \(err)")
}
else {
// Ensure that if there's nothing in the document that the function returns
guard let snap = snapshot else {return}
// Parse the data to the customer model
let data = snap.data()
let name = data?["name"] as? String ?? ""
let surname = data?["surname"] as? String ?? ""
let email = data?["email"] as? String ?? ""
let contact = data?["contact no"] as? String ?? ""
// Create the customer and pass it to the global variable
let cus = Customer(name: name, surname: surname, contactNo: contact, email: email)
self.customer = cus
}
completion()
}
}
getDataFromFirebase{
customerRefCollection = Firestore.firestore().collection("customers")
nameLabel.text = customer?.name
surnameLabel.text = customer?.surname
emailLabel.text = customer?.email
contactLabel.text = customer?.contactNo
}
So what you're basically doing here is you're first getting the data from the firebase and only after this work is done, hence the completion block you will be setting your data to the view. You can call the method simply in viewDidLoad.

unable to send Firebase document ID in from VC to VC

i'm running a query to firebase and i'm able to obtain the documentID but i'm not able to send the documentID over to another VC. I get everything int he query with no issues. I'm not sure what i'm missing. Any suggestions are greatly appreciated.
First VC
#IBAction func getDataTapped(_ sender: Any) {
SVProgressHUD.show()
if HOSP != (hospNameTxt.text!) {
ptListQuery = ptListCollectionRef?.whereField("hosp", isEqualTo: (hospNameTxt.text!))
}
ptListQuery?.getDocuments { (snapshot, error) in
if let err = error {
debugPrint("error getting data: \(err)")
} else {
guard let snap = snapshot else { return }
for document in snap.documents {
let data = document.data()
let ptName = data[PTNAME] as? String ?? ""
let assignedMd = data[ASSIGNEDMD] as? String ?? ""
let officeMd = data[OFFICEMD] as? String ?? ""
let assignedDate = data[ASSIGNEDDATE] as? String ?? ""
let seeNoSee = data[SEENOSEE] as? String ?? ""
let room = data[ROOM] as? String ?? ""
let app = data[APP] as? String ?? ""
let documentId = document.documentID
let username = data[USERNAME] as? String ?? ""
let userId = data[USER_ID] as? String ?? ""
let newPtList = PTList(ptName: ptName,
assignedMd: assignedMd,
officeMd: officeMd,
assignedDate: assignedDate,
seeNoSee: seeNoSee,
room: room,
app: app, documentId: documentId,
username: username, userId: userId
)
self.ptListInCell.append(newPtList)
print("docID", documentId) //this shows the documentID in the console
print(document.data()) //this shows everything in the array but the document ID
}
}
self.performSegue(withIdentifier: "goToResults", sender: self)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "goToResults" {
let vc = segue.destination as! ResultsdataVC
vc.ptListFromCell = ptListInCell
SVProgressHUD.dismiss()
}
}
Second VC
class ResultsdataVC: UIViewController, UITableViewDataSource, UITableViewDelegate, PatListCellDelegate {
#IBOutlet weak var resultsTableView: UITableView!
#IBOutlet weak var patientFilter: UISegmentedControl!
var ptListFromCell = [PTList]()
var ptDatasToPass = [PTData]()
var selectedFilter = FilterCategory.hosp.rawValue
var patientListener: ListenerRegistration!
var patientCollectionRef: CollectionReference!
//segmentedControl
var dataFilter = 0
var tableDataSee : [String] = ["Yes"]
var tableDataNoSee : [String] = ["No"]
override func viewDidLoad() {
super.viewDidLoad()
resultsTableView.delegate = self
resultsTableView.dataSource = self
resultsTableView.rowHeight = 110
}
here is PTList model:
class PTList {
private(set) var ptName: String!
private(set) var assignedMd: String!
private(set) var officeMd: String!
private(set) var assignedDate: String!
private(set) var seeNoSee: String!
private(set) var room: String!
private(set) var app: String!
private(set) var documentId: String!
private(set) var username: String!
private(set) var userId: String!
init(ptName: String, assignedMd: String, officeMd: String, assignedDate: String, seeNoSee: String, room: String, app: String, documentId: String, username: String, userId: String) {
self.ptName = ptName
self.assignedMd = assignedMd
self.officeMd = officeMd
self.assignedDate = assignedDate
self.seeNoSee = seeNoSee
self.room = room
self.app = app
self.documentId = documentId
self.username = username
self.userId = userId
}
}
here is my db structure