https://github.com/polidea/plxobservers
Small tool for fast implementation of multi-observer pattern in Objective-C
https://github.com/polidea/plxobservers
Last synced: 10 months ago
JSON representation
Small tool for fast implementation of multi-observer pattern in Objective-C
- Host: GitHub
- URL: https://github.com/polidea/plxobservers
- Owner: Polidea
- License: mit
- Created: 2015-11-12T09:17:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-05T10:56:40.000Z (over 10 years ago)
- Last Synced: 2025-02-11T19:03:55.006Z (over 1 year ago)
- Language: Objective-C
- Size: 11.7 KB
- Stars: 1
- Watchers: 18
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PLXObservers
[](https://travis-ci.org/Polidea/PLXObservers)
[](http://cocoapods.org/pods/PLXObservers)
[](http://cocoapods.org/pods/PLXObservers)
[](http://cocoapods.org/pods/PLXObservers)
Small tool for fast implementation of multi-observer pattern in Objective-C
## Usage
Given you have a observer protocol (basicly the same as a delegate protocol):
```Objective-C
@protocol ObserverProtocol
- (void)somethingDidHappen:(NSString *)message more:(NSInteger)more;
@end
```
Create an instance of PLXObservers with your delegate protocol:
```Objective-C
PLXObservers *observers = (PLXObservers *)[[PLXObservers alloc] initWithObserverProtocol:@protocol(ObserverProtocol)];
```
Add/remove as many observers (implementing your PLXObservers) as you like:
```Objective-C
[observers addObserver:myObserver1]
[observers removeObserver:myObserver2]
```
Calling a ObserverProtocol method on the PLXObservers instance will be forwarded to the registered observers:
```Objective-C
[observers somethingDidHappen:@"test" more:123]
```
## Installation
PLXObservers is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
pod "PLXObservers"
## Author
Antoni Kedracki, akedracki@gmail.com
Polidea
## License
PLXObservers is available under the MIT license. See the LICENSE file for more info.