|
Hello all, my name is Kay and I am new to swiftui. I try to build my first countdown app with swiftui. Countdown is already working but I am not able to change the countdowntime from another view. I have 2 pickers on the other view and a save textfield which is a navigationlink. When I press the save textfield I want to save the total_min from the DetailView to the defaultTimeRemaing from the main view. I've searched the internet for solutions, but now I am more confused then before. I am not asking for code, just for giving me a hint where to start. Thanks in advance. Here is what I have so far:
|
|
Okay, as you just wanted a hint what to look for I've got something for you: What is the @Binding property wrapper? |
|
|
|
@Hatsushira Thanks for the hint. If I understand it correctly, the bound variable is changed immediately. That's not what I try to do. Only when I press the save button, the variable in the main view should change. I think I need to check for global variable? Thanks Kay |
|
Yes. But you don't have to set it immediately. You can use a local variable in your DetailView set the bound variable to your local value in your Save action. So the bound variable wouldn't be changed when you don't click save. |
|
|
|
For any reason, @binding didn't work. I got it working with @appstorage. But "coding" with copy and paste doesn't make sense. That's why I decided to stop this project and begin to learn the basics first. Thanks for your help Kay |
|
Sorry, to hear that. I did try it with your code and it worked for me. Perhaps, the call side for your DetailView was the obstacle. I'm sure we can help you while you learn the basics. Paul has an excellent starter course. For me personally, Sean Allen has gread courses, too. |
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.
Sponsor Hacking with Swift and reach the world's largest Swift community!
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.
Link copied to your pasteboard.