There is a very unpleasant behavior for select queries, as described by Apple:
If the object in the context has been changed, the predicate is evaluated by its changed state, and not by the current state in persistent storage. Therefore, if the object in the context has been changed in such a way that it satisfies the criteria of the select queries, the query retrieves it even if the changes were not stored in the repository and the values ββin the repository are such that they do not meet the criteria. Conversely, if the object in the context has been changed so that it does not match the query, the query will not retrieve it, even if the version in the repository does not match.
Perhaps you will clear the date elsewhere, and the fetch request includes results in which the date is nil in memory but still set to disk (in persistent storage), and therefore, when an object causes an error, it loads the object with the installed date.
My only advice would be to coordinate access to the context of the managed entity (for example, on NSOperationQueue ) so that any updates can be stored in persistent storage before executing the select query.
Frank Schmitt Dec 11 '17 at 19:36 2017-12-11 19:36
source share