UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Advice for a problem with the dismiss button

Forums > SwiftUI

I'm making my first app, and I have a favourite button on a page 3 pages deep. When you push the back button to go to the contentview which just uses a (@Environment(.dismiss) private var dismiss1) to go back. On the contentView I have a fav.count() showing the number of favourites selected but it doesn't update unless I close the app and restart it.

But I have just realised that instead of a dismiss, if I use a .fullscreencover (like below to go back) then it updates. But I feel somehow this will cause problems.

Question is does anyone know why it's not updating with the dismiss button or what i can do to make it update or do you know if using the .fullscreencover to go back to the home page is ok to do?


.fullScreenCover(isPresented: $contentPage) { contentPage() }


Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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

Reply to this topic…

You need to create an account or log in to reply.

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.