0
votes

looking to delete the records when two attributes of same table are same (%k1 = %k2).

Example in table User, delete records which has User.firstName == User.lastName. Note NSPredicate(format: "firstName != lastName") does not help even to fetch records.

Looks a kind of self join, which not the way core data works, but have some requirement to delate such records in same table. Any help in predicate please

1
"Does not help" - does it throw an error, or fetch nothing, or fetch everything?pbasdf
fetches all records to delete..mkumar
That predicate fetches instances where they're not equal. You want where they are equal, right?Tom Harrington
need of some way to delete the records where two attributes are equal..mkumar

1 Answers

0
votes
  • Fetch all data.
  • Filter let duplicates = users.filter { $0.firstName == $0.lastName }.
  • Delete the found items.