有人可以提供一个使用 ReactiveCocoa 抽象来实现这样的事情的单行示例:
// pseudo-code
NSMutableArray *array = @[[] mutableCopy];
RACSignal *newValue = RACAbleWithStart(array); // get whole array or maybe just added/removed element on push/pop
[newValue subscribeNext:^(NSArray *x) {
// x is whole array
}]
[newValue subscribeNext:^(id x) {
// x is new value
}]
[newValue subscribeNext:^(id x) {
// x is removed value
}]
我看到 NSArray 的一些扩展被删除以支持 Mantle https://github.com/ReactiveCocoa/ReactiveCocoa/pull/130但仍然找不到 NSArray 操作的简单示例。