I'm developing an iOS application with iOS SDK 6.0 and XCode 4.5.2. My target development is 4.3.
I'm using Core Data to manage my data. Now I have this NSPredicate
to search shops:
if ((shopSearchBar.text != nil) && ([shopSearchBar.text length] > 0))
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name = %@",shopSearchBar.text];
[fetchRequest setPredicate:predicate];
}
This is Shop entity:
I have to convert name to lowercase and see if it contains shopSearchBar.text
in lowercase format.
Example:
I have these four shops:
If user search text is 'shop', it must returns all of them.
Do you know how to do that?
This is how I've solved my problem:
if ((shopSearchBar.text != nil) && ([shopSearchBar.text length] > 0))
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@",
shopSearchBar.text];
[fetchRequest setPredicate:predicate];
}