NEW: Learn to build the incredible iOS 15 Weather app today! >>

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)

1      

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

   

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.

   

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.

   

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

   

@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)

   

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

   

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

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED Only until this Sunday, December 12th, you can join a free crash course to learn advanced techniques for testing new and legacy Swift code — it's the fast track to becoming a complete Senior iOS Developer!

Click to learn more

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.