Search code examples
swiftcore-dataswift4swift4.1

Fetch request not working in Swift 4.1


I have a predicate that is a Bool set to false (mostly). It stopped working correctly in Swift 4.1 when I upgraded yesterday.

The predicate is:

requestData.predicate = NSPredicate(format: "delete == %@", false as CVarArg);

How do I check if this value is false in the Core Data store? Thanks.


Solution

  • The placeholder %@ is for objects, the placeholder for a Bool is %d

    However there is a simpler syntax if the argument is a constant

    requestData.predicate = NSPredicate(format: "delete == FALSE")