Module 2 wrap up challene

I’m badly stuck on iOS foundations module 2 wrap up challenge of movie tracker app can anybody help me how to write the codes

@sukainaf13

Welcome to the community.

I decided to do this challenge just as an exercise. There are enough clues in the description to point you in the right direction and the previous project MenuApp gives you the essentials for the project structure. There are a couple of tricky elements.

From the instructions given you need to have a List that displays an array of data which are your movies.

Below that list you need two buttons. The first changes the List to show only those that have not been watched and the second changes the List to those that have been watched.

Looking at the images Chris Ching has supplied, you can see that there is a title that changes depending on what data is being displayed. That tells you that the Navigation Title needs to change depending on which button you press.
(Hint) so you need to have a @State property in that View to store the list title and use that variable in your navigation title.

Each movie has the following properties:
title
year
director
description
rating
and a boolean that enables you to flag if it has been watched or not

When you covered the menuApp you will remember that the struct that defines the data needed to be Identifiable so you need to add a property to the struct to satisfy that requirement.

The 4th instruction says to use a DataService to serve up the data and it should have 2 functions

  • 1 serves up movies that are not watched
  • 2 serves up movies that are watched

Going back to the menuApp you can also include a function to serve up the sample data that is described.

hi chris thank you so much for your concern. But i am still confuse that how could a button change the list while navigation link is not been taught yet

Navigation Links were used in the MenuApp but in the case of this challenge they are not required since you are not transitioning to a DetailView like you did in the MenuApp.

In the case of the first button it selects all the records where the movies have not been watched. So in the function notWatched() in DataService you must go through all the records and select just those where they are flagged as not having been watched. The boolean value in your data model should be set to indicate that some have been watched and some have not been watched. Let’s say that you named that property watched. For those that have not been watched you would set that to false and for those that have been watched you would set that to true.

So in your DataService function notWatched(), you have to write code that extracts the records where the movies have not been watched and so you would select those records where the property watched is set to false.