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

Portfolio App Notifications Problem

Forums > Videos

I just finished the video and I'm having the same problem with .onChange(update) just dismissing the screen after tapping and trying to enter a time. I was able to solve this by removing the onChange(update) from both $remindMe and the $reminderTime as shown below. Of course you would need to do the initial workaround that was posted earlier for EditProjectView concerning the onChange(update) problem some of us were having. I haven't moved from 12.4 yet so maybe some of you have better luck with another version of xcode regarding this. Anyway, I hope this helps anyone who might be having this issue.

Section(header: Text("Project reminders")) { Toggle( "Show Reminders", isOn: $remindMe.animation()) .alert(isPresented: $showingNotificationsError) { Alert(title: Text("Ughh"), message: Text( "Make sure notifications are enabled"), primaryButton: .default(Text( "Check Settings"), action: showAppSettings), secondaryButton: .cancel()) }

            if remindMe {
                DatePicker(
                    "Reminder Time", selection: $reminderTime,
                    displayedComponents: .hourAndMinute)

6      

Just did this using Xcode 12.4 and worked fine, best if you update to it.

If you want to change between Xcode version you can use this tool to help you from RobotsAndPencils XcodesApp

5      

Perfect in Xcode 12.5 beta. I had the same issue with 12.4 as you did @James (on simulator - never checked on real device). Rotating the simulator in 12.4 to landscape then back to portrait, and it worked fine too, but only once then the but reappears, so you would have to rotate again.

5      

Thanks @NigelGee and @Andeanie for the reples. I downloaded 12.4 and the latest Beta version and still the same problem. I rewatched the original EditProjectView Video, skipped the simulator and tested on my iphone 12 to make sure of no errors. It still dismisses the screen even in landscape mode. So again, thanks to @NigelGee's workaround:

/* The problem seem to be with update(). I found a work-a-round for time being is to

remove .onChange(update) from both TextFields remove update() from .onTapGesture in colorButton add dataController.save() to func update() change .onDisappear to .onDisappear(perform: update) */

It works perfectly and the notification reminders work as well..

So Thank you @NigelGee, I think you should have a dedicated "AWARD" on the AwardsView for this solution.

5      

The original code works again. I recently cleared my cache and restarted xcode and to my delight, it works again.

5      

@James, when you post code, please put three backticks ``` on the line before your code block and three backticks ```on the line after your code block. That will format it nicely for display on the forum so that it is easier for others to read your code and copy/paste it to try out solutions. It is rather difficult to read code and figure out what it's doing when it's all run together like a paragraph.

This:

Section(header: Text("Project reminders")) { Toggle( "Show Reminders", isOn: $remindMe.animation()) .alert(isPresented: $showingNotificationsError) { Alert(title: Text("Ughh"), message: Text( "Make sure notifications are enabled"), primaryButton: .default(Text( "Check Settings"), action: showAppSettings), secondaryButton: .cancel()) }

        if remindMe {
            DatePicker(
                "Reminder Time", selection: $reminderTime,
                displayedComponents: .hourAndMinute)

vs this:

Section(header: Text("Project reminders")) {
    Toggle( "Show Reminders", isOn: $remindMe.animation())
        .alert(isPresented: $showingNotificationsError) {
            Alert(title: Text("Ughh"), message: Text( "Make sure notifications are enabled"), primaryButton: .default(Text( "Check Settings"), action: showAppSettings), secondaryButton: .cancel())
        }

    if remindMe {
        DatePicker(
            "Reminder Time", selection: $reminderTime,
            displayedComponents: .hourAndMinute)

5      

Thanks @roosterboy, I was wondering why it didn't post as I had intended. Now I know, thanks again.

5      

Having the same issue as above and moving update() to onDisappear worked.

5      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.