Relative Content

Tag Archive for swiftswiftuiwidgetkitappintents

.onChange it’s not working when the value of @AppStorage changes

I’ve trying to do that ExecuteShortcutIntent changes viewModel wasExecuted to true, and then it would making the user defaults shortcutWasExecuted variable changes too, and then modify the ShortcutView due to @ObservedObject var viewModel and .onChange. but it turns out that onChange is not called, even that wasExecuted changes to true. Is there something wrong in the approach i’m trying to use? What I’m doing wrong?

Is it possible to receive parameters in app intent constructor before execute the ‘perform’ method?

I’m trying to receive a parameter in my app intent struct constructor to perform an action using this parameter value, but the perform method executes before my own init being executed. By the way, the WidgetConfigurationIntent protocol forces me to have an empty init, even I already have my own constructor, so I need to have two constructors, and the first one that is executed is the empty constructor and then the perform method. So, my ‘custom’ constructor is executed only after these two. That way, I always receiving nil when I going to use the value of myParameter in my perform intent method.