2

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?

Lucas
  • 6,675
  • 3
  • 25
  • 43

1 Answers1

2
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);