Created
December 2, 2015 13:07
-
-
Save AdityaDeshmane/23f8b59c3180c977c56b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Input Data sample | |
SWSearchContact *contactModel = [[SWSearchContact alloc] init]; | |
contactModel.arrPhoneNumbers = [arrPhoneNumbers copy]; | |
contactModel.strFirstName = firstName ? firstName : @""; | |
contactModel.strMiddleName = middleName ? middleName : @""; | |
contactModel.strLastName = lastName ? lastName : @""; | |
[_arrMutContacts addObject:contactModel]; | |
*/ | |
NSArray *filteredArray = nil; | |
NSPredicate *predicate; | |
//E.g 1 : Search on string | |
predicate = [NSPredicate predicateWithFormat:@"strFirstName contains[c] %@ OR strMiddleName contains[c] %@ OR strLastName contains[c] %@",_strName,_strName,_strName]; | |
//E.g 2 : Search inside array for string | |
predicate = [NSPredicate predicateWithFormat:@"ANY SELF.arrPhoneNumbers contains[c] %@", _strPhoneNumber]; | |
filteredArray = [_arrMutContacts filteredArrayUsingPredicate:predicate]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment