[DataBinding] add observe addObjectsFromArray:
@@ -265,6 +265,21 @@ shold override five primitive methods
[self mlnui_notifyAllObserver:NSKeyValueChangeReplacement indexSet:set newValue:object oldValue:oldValue];
// )
} forceAddOriginImpBlock:placeholderBlock];
+
+ origin = @selector(addObjectsFromArray:);
+ swizzle = @selector(mlnkvo_addObjectsFromArray:);
+ [cls mlnui_swizzleInstanceSelector:origin withNewSelector:swizzle newImpBlock:^(NSMutableArray *self, NSArray* objects) {
+ // call real imp
+ GetIMP();
+ ((void(*)(id,SEL,id))imp)(self, origin, objects);
+ // call observer
+ if (objects && objects.count) {
+ for (int i = 0; i < objects.count; i++) {
+ NSIndexSet *set = [NSIndexSet indexSetWithIndex:self.count + i];
+ [self mlnui_notifyAllObserver:NSKeyValueChangeInsertion indexSet:set newValue:objects[i] oldValue:nil];
+ }
+ }
+ } forceAddOriginImpBlock:placeholderBlock];
}
#pragma clang diagnostic pop
