Udai kumar Udai kumar - 1 year ago 73
iOS Question

How to get unmatched elements in an nsmutablearray

I have a

. I filtered matched data with
but i want that array element which is not matched.

Can anyone help me.

Answer Source

You can use NOT with the predicate for that

NSArray *arrValues = [NSArray arrayWithObjects:@"Hello",@"Hello One",@"Good Morning", nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (SELF CONTAINS %@)",@"Hello"];  
NSArray *arrFiltered  = [arrValues filteredArrayUsingPredicate:predicate];


   "Good Morning"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download