I have 2 arrays, one contains a set of ID's and one contains a set of objects (similar to below):
NSArray *identifierArray = @[@100, @200, @300];
NSArray *peopleArray = @[@{@"id": @100, @"name": @"Ben"}, @{@"id": @200, @"name": @"Alex"}, @{@"id": @300, @"name": @"Sarah"}, @{@"id": @400,@"name": @"George"}, @{@"id": @500, @"name": @"Jessica"}];
I want to be able to loop through the peopleArray and check if any of the objects has an ID that appears in identifierArray. If a match is found, it should remove the object from the identifierArray, which would result in:
NSArray *peopleArray = @[@{@"id": @400,@"name": @"George"}, @{@"id": @500, @"name": @"Jessica"}];
I've tried some variations of for loops to loop through each object, then loop through each ID in peopleArray, as below, but it doesn't remove any objects, even though there are objects it should be removing.
for (NSNumber *id in activePeople) {
for (int i = 0; i < peopleArray.count; i++) {
if (id == [peopleArray[i] valueForKey:@"id"]) {
NSLog(@"Should remove...%@")
}
}
}
Can anyone point me in the direction of how i might go about this?