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

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -