Multiple lists
Now that we have items created for one list, let's see how we can add multiple Shopping Lists to our app. It's quite similar to what we just did for Items, but before we get started, let's refactor our code so that it becomes easier to add a new Shopping List View Controller.
Refactoring to share code
Perform the following steps:
- Create a new empty Swift file in our
Controllers
folder and call itBaseTableViewController.swift
. - Inside of our
BaseTableViewController.swift
file, create a new class that inherits from theUITableViewController
and has arequestInput
method:
import UIKit class BaseTableViewController: UITableViewController { func requestInput(title: String, message: String, handler: @escaping (String) -> ()) { let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) alert.addTextField(configurationHandler: nil) alert.addAction(UIAlertAction(title...