0
    protocol HasWaitAnimation: UIViewController {
    
    var alertWait: ActivityViewController? {get set}
}


extension HasWaitAnimation where Self: UIViewController {
    func showAlertWait(message: String, completion: @escaping()->Void) {

        DispatchQueue.main.async {
            
            let activitiyViewController = ActivityViewController(message: message)
            self.present(activitiyViewController, animated: false, completion: {
                completion()
            })
            
            self.alertWait = activitiyViewController
            
        }

    }
    
    func hideAlertWait (completion: @escaping () -> Void) {
        DispatchQueue.main.asyncAfter(deadline: .now()+0.2, execute: {
            self.alertWait?.dismiss(animated: true, completion: completion)
            self.alertWait = nil
        })
        
        
    }
    
}

在 Xcode 13 上我得到

“冗余超类约束‘Self’:‘UIViewController’”

在线

“扩展 HasWaitAnimation where Self: UIViewController {”

我该如何解决这个问题?

4

0 回答 0