Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSMutableArray removeObjectsInArray #2921

Open
sakrist opened this issue Feb 14, 2019 · 0 comments
Open

NSMutableArray removeObjectsInArray #2921

sakrist opened this issue Feb 14, 2019 · 0 comments

Comments

@sakrist
Copy link
Contributor

sakrist commented Feb 14, 2019

Wrong implementation of removeObjectsInArray.

If we pass self object to removeObjectsInArray it will remove half of itself objects.

Received array must be copied or converted to set. if it's the same object to receiver, then removeAllObjects.

- (void)removeObjectsInArray:(NSArray *)other
{
    if (self == other) {
        [self removeAllObjects];
        return;
    }

    NSSet *set = [[NSSet alloc] initWithArray:other];
    for (id obj in set)
    {
        [self removeObject:obj];
    }
    [set release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant