tl;dr: I'm having trouble figuring out how to segue from my NewTransactionViewController back to my main CollectionViewController and when going back, adding the data from the NewTransactionViewController into my collection list view. What I've found online is either too basic for what I need or too sophisticated. Essentially I'm trying to mimic a UITableView but I'm using collections for more dynamic capabilities later on (plus I want the option of multiple columns).
I'm new to programming and am trying to set-up a simple budget app to log transactions. Goal is for the user to add a new transaction by filling in details and when they click "save", it goes back to the previous VC and adds those details and updates the collection view.
Thanks in advance for the help!
// ViewController.swift
import UIKit
class NewTransactionViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate
{
//Add new transaction cell to master list
@IBAction func addNewTransaction(_ sender: UIBarButtonItem)
{
//Unsure how to implement
}
class CollectionViewController: UICollectionViewController
{
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as UICollectionViewCell
let categoryLabel = cell.viewWithTag(1) as! UILabel
categoryLabel.text = categoryArray[indexPath.row]
let balanceLabel = cell.viewWithTag(2) as! UILabel
balanceLabel.text = balanceArray[indexPath.row]
return cell
}
}
Storyboard Layout Example