case insensitive NSPredicate with single result in CoreData case insensitive NSPredicate with single result in CoreData ios ios

case insensitive NSPredicate with single result in CoreData


As Dave DeLong said, you can use:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"UPC ==[c] %@ OR ItemID ==[c] %@", aUPCCode,aUPCCode];

Edit:

Use ==[c] instead of ==[cd] or you get accents too (abcd == àbcd).


As Sinetris said, the above works in Objective-C.

It works for case-insensitive. Fetches all results which have the "example" string value in it.

Update Swift 4.0/5.0

let predicateIsNumber = NSPredicate(format: "keywordContactNo contains[c] %@", example!) 

Hope it helps

Thanks


maybe this:

[NSPredicate predicateWithFormat:@"UPC MATCHES[cd] %@ OR ItemID MATCHES[cd] %@",aUPCCode,aUPCCode];