Можете ли вы помочь мне преобразовать эти if
заявления в switch
с делами, пожалуйста?
Некоторое время я борюсь и не могу понять, как заставить это работать.
Вот код:
class Settings: NSObject {
let name: SettingsName
let imageName: String
init(name: SettingsName, imageName: String){
self.name = name
self.imageName = imageName
}
}
enum SettingsName: String {
case settings = "Settings"
case terms = "Terms & privacy policy"
case feedback = "Send Feedback"
case help = "Help"
case switchAccount = "Switch Account"
case cancel = "Cancel"
}
@objc func handleDismiss(setting: Settings) {
UIView.animate(withDuration: 0.5, animations: {
self.blackView.alpha = 0
if let window = UIApplication.shared.keyWindow {
self.collectionView.frame = CGRect(x: 0, y: window.frame.height, width: self.collectionView.frame.width, height: self.collectionView.frame.height)
}
}, completion: { (_) in
if setting.name == .settings {
self.homeController?.showControllerForAccountSettings(setting: setting)
}
if setting.name == .terms {
self.homeController?.showControllerForTermsAndPrivacy(setting: setting)
}
else if setting.name != .cancel && setting.name != .settings{
self.homeController?.showDummyControllerForSetting(setting: setting)
}
})
}