First, we will start saving reviews in Core Data. Open up ReviewFormViewController.swift and, above @IBOutlets, add the following variable:
var selectedRestaurantID:Int?
Next, delete all of the print statements inside your onSavedTapped(:) method and then add the following:
@IBAction func onSaveTapped(_ sender: Any) {
var item = ReviewItem()
item.name = tfName.text
item.title = tfTitle.text
item.customerReview = tvReview.text
item.restaurantID = selectedRestaurantID
item.rating = Float(ratingView.rating)
let manager = CoreDataManager()
manager.addReview(item)
dismiss(animated: true, completion: nil)
}
This code is all we need to save an item in Core Data using CoreDataManager. To display reviews for a particular restaurant, we need to save every review with a restaurant identifier. Then, when we go to a certain restaurant, we...