ios - search arrays with NSPredicate to return results and matches -
hi i'm using nspredicate search objects of nsarrays against 5 elements array, , result back. there way matched results returned nspredicate string (among 5 elements array) against match succeeded?
try ,
this predicate gives array not contains substring.
nspredicate *predicate = [nspredicate predicatewithformat:@"not self contains '%@'",searchstring]; nsarray *array = [nsarray arraywithobjects:@" ahfja ", @"test1", @"best", @"anta", nil]; nsarray *filteredarray = [array filteredarrayusingpredicate:predicate ]; nslog(@"%@",filteredarray ); o/p:-
( ahfja, best, anta ) it gives array contains substring
nspredicate *predicate = [nspredicate predicatewithformat:@"self contains '%@'",searchstring]; nsarray *array = [nsarray arraywithobjects:@" ahfja ", @"test1", @"best", @"anta", nil]; nsarray *filteredarray = [array filteredarrayusingpredicate:predicate ]; nslog(@"%@",filteredarray ); o/p:-
( test1, )
Comments
Post a Comment