Replacing the UI classes
At this moment, you know how to migrate the model part of an application. However, in real life, we also have to replace the graphical classes. Doing this is not complicated, but this could include a bit full of details.
Getting ready
Continuing with the previous recipe, make a copy of it or just commit the changes you have and let's continue with our migration.
How to do it...
Now, follow these steps to replace the UI classes:
First, create a new file called
MainViewController.swift
and start importing UIKit:import UIKit
The next step is to create a class called
MainViewController
. This class must inherit fromUIViewController
and implement theUITableViewDataSource
andUITableViewDelegate
protocols:class MainViewController:UIViewController,UITableViewDataSource, UITableViewDelegate {
Then, add the attributes we had in the previous view controller. Keep the same name you used before:
private var vehicles = [Car]() @IBOutlet var tableView:UITableView!
Next, we need...