Adding the rating to the movie cell

Currently, the movie table view displays cells that have a title. UITableViewCell has a built-in option to display a title and a subtitle for a cell. Open Main.storyboard and select the prototype cell for the movies. In the Attributes Inspector field, change the cell's style from basic to subtitle. This will allow you to use detailTextLabel on the table view cell. This is where we'll display the movie rating.

In MoviesViewController, add the following line to tableView(_:cellForRow:atIndexPath:), right after you set the cell's title:

cell.detailTextLabel?.text = "Rating: (movie.popularity)" 

This line will put the movie's popularity rating in a string and assign it as a text for the detail text label.

If you build and run your app now, all movies should have a popularity of 0.0. Let's fix this by resolving the networking issue.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset