nspredicate

case insensitive NSPredicate with single result in CoreData

只谈情不闲聊 提交于 2021-01-16 12:28:13
问题 Here is my current NSPredicate: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"UPC==%@ OR ItemID==%@", aUPCCode,aUPCCode]; How can I make this case insensitive? And I do not want to do any partial matching. Example if they enter 123 for aUPCCode I do not want to get 123, 123a, 123b, 123c, ect. I would only want an exact match. I thought about doing this but it seems a little ridiculous: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"UPC==%@ OR ItemID==%@ OR UPC==%@

case insensitive NSPredicate with single result in CoreData

五迷三道 提交于 2021-01-16 12:27:07
问题 Here is my current NSPredicate: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"UPC==%@ OR ItemID==%@", aUPCCode,aUPCCode]; How can I make this case insensitive? And I do not want to do any partial matching. Example if they enter 123 for aUPCCode I do not want to get 123, 123a, 123b, 123c, ect. I would only want an exact match. I thought about doing this but it seems a little ridiculous: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"UPC==%@ OR ItemID==%@ OR UPC==%@

How to apply multiple filters to realm database results

青春壹個敷衍的年華 提交于 2020-07-10 07:47:50
问题 I am new to programming & trying to apply filters using UISwitches Currently I have: A realm database returning all the objects A UI that uses Switches to send filters Things Attempted: Subqueries, however I don't know the proper format to write it for realm Goal: Apply multiple filters to realm database results User Interface: Realm Database: class Question: Object { @objc dynamic var neverAttempted: Bool = true @objc dynamic var correct: Int = 0 @objc dynamic var flagged: Bool = false @objc

How to apply multiple filters to realm database results

杀马特。学长 韩版系。学妹 提交于 2020-07-10 07:47:04
问题 I am new to programming & trying to apply filters using UISwitches Currently I have: A realm database returning all the objects A UI that uses Switches to send filters Things Attempted: Subqueries, however I don't know the proper format to write it for realm Goal: Apply multiple filters to realm database results User Interface: Realm Database: class Question: Object { @objc dynamic var neverAttempted: Bool = true @objc dynamic var correct: Int = 0 @objc dynamic var flagged: Bool = false @objc

How to validate NSPredicate before calling fetch

老子叫甜甜 提交于 2020-06-29 06:13:59
问题 I create a search NSPredicate using a custom format string. Sometimes the syntax of this string is wrong and when I execute a fetch using a NSFetchRequest with this predicate I get a NSInvalidArgumentException , for example when the key-path is incorrect. I would much rather prefer to validate this predicate (call some method that returns YES if format is ok), than have an exception thrown that crashes my app. What can I do? To rephrase the inquiry into a simple question: Can I validate the