DelegateCenter 1.1.0

DelegateCenter 1.1.0

Maintained by shangenzhang.



  • By
  • install-b

DelegateCenter

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

subscript protocol

/// 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()
}
        

Requirements

Installation

DelegateCenter is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'DelegateCenter'

Author

install-b, [email protected]

License

DelegateCenter is available under the MIT license. See the LICENSE file for more info.