Skip to content

install-b/DelegateCenter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, 645256685@qq.com

License

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