Post

Replies

Boosts

Views

Activity

Problem when working with .onChange and .onAppear modifier
Hey, I am currently struggling with this issue where I just can't wrap my head around. First I want to explain my goal. After completing a certain task within my view model, I want to trigger an alert popup. For this I have a @Published property which is just a basic enum containing .success and .failure which will be set after the task is done. On my view side I basically want to listen to that change and therefore trigger a state property called showAlert which the triggers the alert. VStack { loadingView } .onChange(of: viewModel.alertType) { type in if type != nil { showAlert = true } } .alert( alertTitle(for: viewModel.alertType), isPresented: $viewModel.isPresentingAlert, presenting: viewModel.alertType ) { type in alertActions(for: type) } message: { type in Text(alertMessage(for: type)) } .onAppear { viewModel.onAppear() } My View Model contains these properties: @Published var alertType: AlertType? @Published var isPresentingAlert = false During debugging I figured out that the .onChange doesn't get triggered at all. So I started commenting pieces of my code and figured out that the issue is in the .onAppear modifier. I really can't wrap my head around what the issue is here. To me thats a strange behavior. Can someone help here?
1
0
1.1k
Jul ’23
CTCellularPlanProvisioning.supportsCellularPlan returns false on eSIM supported devices (CRITICAL)
Working for a telephony provider, I had to implement something that checks if the device supports eSIM. And when checking on a device like iPhone 13 Pro it returns false. Why is that the case? Can someone help? var supportsESIM: Bool { cellularPlanProvisioning.supportsCellularPlan() } private let cellularPlanProvisioning = CTCellularPlanProvisioning()
3
0
503
Jul ’23