草庐IT

AlertPresentable

全部标签

swift - Kotlin 中的条件接口(interface)

在Swift中,我们可以根据条件定义一个可以被class或struct遵循的协议(protocol):protocolAlertPresentable{funcpresentAlert(message:String)}extensionAlertPresentablewhereSelf:UIViewController{funcpresentAlert(message:String){letalert=UIAlertController(title:“Alert”,message:message,preferredStyle:.alert)alert.addAction(UIAlert