IOS-filter elements in the array
// Array of elements to be removed NSMutableArray * filteredArray = [[NSMutableArray alloc] initWithObjects: @ "1", @ "4", nil]; // The array NSMutableArray * dataArray = [[NSMutableArray alloc] initWithObjects: @ "1", @ "2", @ "1", @ "4 ", @ "6", @ "1", @ "1", @ "4", @ "1", @ "6", @ "4", nil]; /* Method 1: Use NSPredicate. Note: The Cocoa framework of NSPredicate is often used in regular expressions such as passwords and usernames. Similar to the SQL statement NOT, which is NOT SELF, which represents the IN range operator of the string itself, NOT (SELF IN % @) means: NOT the value of the specified string */NSPredicate * filterPredicate = [NSPredicate predicateWithFormat: @ "NOT (self in % @)", filteredArray]; // Filter Array NSArray * reslutFilteredArray = [dataArray filteredArrayUsingPredicate: filterPredicate]; NSLog (@ "Reslut Filtered Array = % @", reslutFilteredArray);/* result: reslut Filtered Array = (2, 6, 6) * // * Method 2: traverse the Array from the back, and then match and delete */int I = (int) [dataArray count]-1; for (; I> = 0; I --) {// containsObject determines whether the element exists in the array (based on the memory address of the two, the same: YES is different: NO) if ([filteredArray containsObject: [dataArray objectAtIndex: I]) {[dataArray removeObjectAtIndex: I] ;}} NSLog (@ "Data Array =% @", dataArray);/* result: Data Array = (2, 6, 6 )*/