DelegateCenter 1.1.0

DelegateCenter 1.1.0

shangenzhang维护。



  • install-b

DelegateCenter

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后从示例目录中首先运行 pod install

下标协议

/// Protocol Way
// declare Protocol
@objc protocol XXXProtocol {
    func aMethod()
}

// on subscribe
DelegateCenter.default.add(self as XXXProtocol)

// cancel subscribe
DelegateCenter.default.remove(self as XXXProtocol)



// send message
DelegateCenter.default.enumDelegate(XXXProtocol.self) { (delegate, _) in
    delegate.aMethod()
}
        
/// Abstract Class Way
// declare Abstract Class
class AClass {
    open func aMethod() {

    }
}

/// 
class SubAClass: AClass {
    overrite func aMethod() {
        // sub Class implemention
    }
}

let aInstance = SubAClass()
DelegateCenter.default.add(aInstance as AClass)


// send message
DelegateCenter.default.enumDelegate(AClass.self) { (delegate, _) in
    delegate.aMethod()
}
        

需求

安装

DelegateCenter可以通过CocoaPods获得。要安装它,只需将以下行添加到您的Podfile中

pod 'DelegateCenter'

作者

install-b, [email protected]

许可证

DelegateCenter 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。