The Save button in the Review Form screen currently just prints the review to the Debug area when tapped. You have updated RestaurantItem to store the restaurant identifier. To save reviews, you'll need to modify the onSaveTapped(_:) method to save a review using Core Data when the Save button is tapped. Do the following steps:
- Click ReviewFormViewController.swift, and add the following property to ReviewFormViewController, above the outlets to store the restaurant identifier:
var selectedRestaurantID:Int?
- Create a private extension, move the onSaveTapped(_:) method into it, and modify it, as shown in the following code block:
private extension ReviewFormViewController {
@IBAction func onSaveTapped(_ sender: Any) {
var item = ReviewItem()
item.name = tfName.text
item.title = tfTitle.text
...