中文文档:中文文档
QOP
(Queen of pain) is a lightweight data binding solution. The bottom layer is implemented with KVO
. Chained calls are elegant and simple, and users do not need to worry about circular references and memory release.
- Quote header files
#import <QOP.h>
- To avoid listening to the same attribute multiple times, you can perform
QOPUNObserve
first, thenQOPObserve
__weak typeof(self) ws = self;
QOPUNObserve(object, identifier);
[QOPObserve(object, identifier) update:^(id observer, id updatedValue) {
ws.title = updatedValue;
}];
- Custom observer and KVO strategy
// QOPKVOPolicy is KVO policy
[QOPSPObserve(observer, target, keypath, QOPKVOPolicyInitial | QOPKVOPolicyAlways) update:^(id observer, id updatedValue) {
NSLog(@"first exe and always exe");
}];
Just add it to Podfile:
pod'QOP'