With NSArray
only i can find values as:
NSArray *arr = [NSArray arrayWithObjects:@"299-1-1", @"299-2-1", @"299-3-1", @"399-1-1", @"399-2-1", @"399-3-1", @"499-1-1", @"499-2-1", @"499-3-1", nil];
NSString *search = @"299";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",[NSString stringWithFormat:@"%@", search]];
NSArray *array = [arr filteredArrayUsingPredicate: predicate];
NSLog(@"result: %@", array);
Found Result
as expected :
result: (
"299-1-1",
"299-2-1",
"299-3-1"
)
But for NSArray
having NSArray
with NSString
NSArray *arr = [NSArray arrayWithObjects:[NSArray arrayWithObjects:@"299-1-1", nil],[NSArray arrayWithObjects:@"399-1-1", nil],[NSArray arrayWithObjects:@"499-1-1", nil], nil];
What will be predicate syntax
here?????
To search in a nested array, you can use the "ANY" operator in the predicate:
Output:
If you want to provide an array of searchTerms then you'll need to change your predicate.
Something like this would do it