GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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?

Thanks


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


2      

Hacking with Swift is sponsored by Essential Developer.

SPONSORED Transform your career with the iOS Lead Essentials. Unlock over 40 hours of expert training, mentorship, and community support to secure your place among the best devs. Click for early access to this limited offer and a FREE crash course.

Click to save your free spot now

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.