I’m working in Swift to attempt to make a listing view that exhibits all of the transactions linked from all of the accounts utilizing Plaid API. However after I run this I get nothing. I’ve tried a number of various things, however nothing is working.
import UIKit
class TransactionViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet var tableView: UITableView!
let communicator = ServerCommunicator()
var transactions: [Transaction] = []
override func viewDidLoad() {
tremendous.viewDidLoad()
title = "Transactions"
tableView.dataSource = self
tableView.delegate = self
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "TransactionCell")
fetchTransactions()
}
personal func fetchTransactions() {
communicator.callMyServer(path: "/server/transactions/get", httpMethod: .get) { (consequence: Consequence<[Transaction], ServerCommunicator.Error>) in
DispatchQueue.primary.async {
swap consequence {
case .success(let fetchedTransactions):
print("Fetched transactions: (fetchedTransactions)") // Debug: Print fetched transactions
self.transactions = fetchedTransactions
self.tableView.reloadData()
case .failure(let error):
print("Did not fetch transactions: (error)") // Debug: Print error if fetch fails
}
}
}
}
// MARK: - UITableViewDataSource
func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
print("Variety of transactions: (transactions.depend)") // Debug: Print variety of rows within the desk
return transactions.depend
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TransactionCell", for: indexPath)
let transaction = transactions[indexPath.row]
// Debug: Print transaction information for every row
print("Transaction at index (indexPath.row): (transaction.date), (transaction.description), $(transaction.quantity)")
cell.textLabel?.textual content = "(transaction.date): (transaction.description) - $(transaction.quantity)"
cell.detailTextLabel?.textual content = transaction.accountName
return cell
}
}