Tejas Tejas - 2 months ago 6
iOS Question

How to perform conditional 'executeFetchRequest' to fetch only those entities where particular attribute is nil?

I want to execute a fetch request where I should get only those entities in result whose particular attributes have a nil value. (say attribute: firstName). So How will I write it in following format ? Everything I have in place, just want to know how to add predicate for nil value condition. This predicate gives me error:
fetchRequest.predicate = NSPredicate(format: "firstName == %@", nil)

Answer

Here you are:

fetchRequest.predicate = NSPredicate(format: "firstName == NIL")
Comments