Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.25 KB

README_zh.md

File metadata and controls

43 lines (31 loc) · 1.25 KB

QOP

CI Status Version License Platform

QOP(Queen of pain)是一款轻量级的数据绑定方案,底层采用KVO实现,链式调用优雅简单,并且使用者不需要关心循环引用及内存释放问题。

如何使用?

  • 引用头文件
#import <QOP.h>
  • 为避免多次监听同一属性可先进行QOPUNObserve,再进行QOPObserve
__weak typeof(self) ws = self;
QOPUNObserve(object, identifier);
[QOPObserve(object, identifier) update:^(id observer, id updatedValue) {
    ws.title = updatedValue;
}];
  • 自定义数据绑定的监听者和监听策略
// QOPKVOPolicy is KVO policy
[QOPSPObserve(observer, target, keypath, QOPKVOPolicyInitial | QOPKVOPolicyAlways) update:^(id observer, id updatedValue) {
    NSLog(@"first exe and always exe");
}];

安装

Podfile中添加即可:

pod 'QOP'