0
votes

I am using SKMaps in my project which is used to download offline maps and I have to use NSPredicatefor search through some collection of SKTPackage.

To display name of the country I am reading "en" value like this

cell.textLabel.text = [package nameForLanguageCode:@"en"];

Now I want to search name of the country from the list. Now to do so I am using following line of code

NSPredicate *resultPredicate = [NSPredicate
                                predicateWithFormat:@"en contains[cd] %@",
                                searchText];

but it is giving me a crash with following message

'NSInvalidArgumentException', reason: 'Can't use in/contains operator with collection (not a collection)'.

Please suggest me what is the correct way of searching this this key using NSPredicate.

1
What is SKTPackage ?Arpit B Parekh
Please see the edit. Its a class in SDKTool framework,user1722889

1 Answers

1
votes

You can search for a country in an array of countries you have already populated using the following lines of codes:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", @“countryName”]; NSArray *results = [countries filteredArrayUsingPredicate:predicate];