to-many Core Data fetch request behaves oddly with a new store

Posted by Giao on Stack Overflow See other posts from Stack Overflow or by Giao
Published on 2010-03-09T21:18:15Z Indexed on 2010/03/15 7:59 UTC
Read the original article Hit count: 275

Filed under:
|

I have two entities, Department and Person. Department has a to-many relationship to Person.

The Person entity has a hireDate property.

I'm using the predicate "count(person) = 0 OR none person.hireDate > %@" to find Departments without any Persons in them or Departments that haven't hired anyone since a recent date.

When the app first starts up (new user experience) and Departments are inserted and no Person have been inserted, the fetch request with this predicate returns nothing. However, if I create insert a new Person entity and delete it, then save the store, the fetch request will return all the Departments.

I've found a work around where, I just insert a new Person and delete it, then save the store, the fetch request as I expected it to work. I've found that inserting a new Person and deleting it without saving will not correct the problem.

Is this a bug with Core Data or is this a bug with how I've designed my app?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core-data