December 2018
Beginner
692 pages
13h 43m
English
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, ...
Read now
Unlock full access