Я пытаюсь переключить вкладку в TabView на основе полученного Push-уведомления. Мой TabView выглядит так:
import SwiftUI
import Combine
struct ContentView: View {
@State var selection = 0
var body: some View {
TabView(selection: $selection){
Получение Push-уведомления и попытка изменить вкладку:
class SceneDelegate: UIResponder, UIWindowSceneDelegate, UNUserNotificationCenterDelegate {
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
(window?.rootViewController?.view as? ContentView)?.selection = 2
Это выдает ошибку - Cannot assign to immutable expression of type 'Int'
. Как я могу это исправить?