всем привет, подскажите пожалуйста, как мне обновить state в менюшке, или может это все вообще по-другому сделать
var bool = true
var menuItems: [UIAction] {
return [
UIAction(title: "Select other city", image: UIImage(systemName: "pencil"), handler: { _ in
if let vc = self.storyboard?.instantiateViewController(identifier: "NavigationCitySearch") as? UINavigationController {
if let citySearchVc = vc.viewControllers.first as? SearchCitiesViewController {
citySearchVc.delegate = self
self.navigationController?.present(vc, animated: true)
}
}
}),
UIAction(title: "Celsius", image: UIImage(named: "celsius"), state: bool ? .on : .off, handler: { _ in
bool = true
return
}),
UIAction(title: "Farenheit", image: UIImage(named: "farenheits"), state: bool ? .off : .on, handler: { _ in
bool = false
return
})
]
}
configurationButton.menu = UIMenu(title: "", identifier: nil, options: [], children: menuItems)
configurationButton.showsMenuAsPrimaryAction = true