如果我像这样使用RACable:
[RACAbleWithStart(self.myProp) subscribeNext:^(id x) {
// Do stuff
}];
如何才能访问myProp的旧值(在更改之前导致信号触发)?所以我可以像这样访问它:
[RACAbleWithStart(self.myProp) subscribeNext:^(id x) {
// Do stuff
id newValue = x;
id oldValue = RAC_oldValue;
}];
答案 0 :(得分:4)
我已成功使用此代码段:
[[object rac_valuesAndChangesForKeyPath:@"property" options:NSKeyValueObservingOptionOld observer:self] subscribeNext:^(RACTuple *tuple) {
id newObject = tuple.first;
NSDictionary *change = tuple.second;
id oldObject = change[NSKeyValueChangeOldKey];
}];