Reputation: 6729
I'm developing for iOS 5, say I have 2 arrays, the second only contains items contained on the first one.
I want to remove this object in every array it's present.
So, is there a way to easily remove an object from all arrays that contains it?
Upvotes: 2
Views: 1716
Reputation: 25692
NSMutableArray *totalArray = [ [ NSMutableArray alloc] init];
//here i assume u want to delete NSString object vijay in all arrays
NSString *toDelete=@"vijay";
[totalArray addObject:firstArray];
[totalArray addObject:secondArray];
for (NSMutableArray *arr in totalArray) {
if ([arr containsObject:toDelete]) {
[arr removeObject:toDelete];
}
}
NSLog(@"firstarry : %@ \n\n",firstArray);
NSLog(@"secondarray : %@ \n\n",secondArray);
Upvotes: 2