Adding an Edit Page
The next step to making a fully functional crud app is adding edit functionality to the. I will need to allow the user to open an edit/details page when a specific review is tapped.
step 1: - add the Show Detail
segue
In XCode, this is done using control - drag from the MealTableViewCell
-> NewMeal
view controller scene
step 2: - pass meal thru segue
in the MealTableViewController
.Prepare()
method, add conditional logic that checks which segue is clicked using
segue.identifier
property. If a review was selected, then pass that data into the segue
step 3: - populate edit form
In MealViewController
, you can check if a meal object was passed from the segue.
If one was, assign the meal properties to the form fields on the edit page.
step 4: - redirect and update the review
Once the user saves their edits, a meal object will be passed back to the unwindToMealList
method in MealTableViewController
.
I then update the meal object and reload that row.