- (void)addObject:(id)anObject filter:(BOOL (^)(id, id))filterBlk { if (anObject == nil) { return; } BOOL isExist = NO; for (id obj inself) { if (!filterBlk(obj, anObject)) { isExist = YES; break; } } if (!isExist) { [self addObject:anObject]; } }
- (void)addObjectsFromArray:(NSArray *)otherArray filter:(BOOL (^)(id, id))filterBlk { if (otherArray.count == 0) { return; } for (id element in otherArray) { [self addObject:element filter:filterBlk]; } }