TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Question about RatingView(rating: .constant(Int(book.rating)))

Forums > 100 Days of SwiftUI

Hey there,

At Bookworm SwiftUI Tutorial 7/10 Paul used RatingView(rating: .constant(Int(book.rating)))

I'm trying to grasp when / why he used .constant here as I want to make sure I understand everything that is going on rather than copy paste blindly. Any ideas?

Thanks! Ran

1      

RatingView is used both in AddBookView and DetailView, however Paul decided that for this design the book rating should not be changed in the DetailView, only in the AddBookView.

So RatingView in DetailView is passed the book rating as a constant (binding).

1      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.