Hi all, I am recieving this runtime error, "[Shopping_List.AddItemViewController save:]: unrecognized selector sent to instance ..." any help would be greatly appreciated, thank you!!
//
// AppDelegate.swift
// Shopping List
//
// Created by Deepak Prasad on 1/10/22.
//
import UIKit
protocol AddItemViewControllerDelegate {
func controller(controller: AddItemViewController, didSaveItemWithName name: String, andPrice price: Float)
}
class AddItemViewController: UIViewController {
@IBOutlet var nameTextField: UITextField!
@IBOutlet var priceTextField: UITextField!
var delegate: AddItemViewControllerDelegate?
// MARK: -
// MARK: View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: -
// MARK: Actions
@IBAction func cancel(sender: UIBarButtonItem) {
dismiss(animated: true, completion: nil)
}
@IBAction func save(sender: UIBarButtonItem) {
if let name = nameTextField.text, let priceAsString = priceTextField.text, let price = Float(priceAsString) {
// Notify Delegate
delegate?.controller(controller: self, didSaveItemWithName: name, andPrice: price)
// Dismiss View Controller
dismiss(animated: true, completion: nil)
}
}
}