Building on this question, I've managed to use undo groups and a single managed object context to handle adding a Cocktail
that can reference existing Ingredients
and/or Brands
.
Now I'm stuck with a UI nit -- in the fetched results controller (sorted by cocktail.name
) you can briefly see an empty row for the to-be-added Cocktail
. Marcus Zarra suggested:
You can add to the predicate to filter out unsaved objects, for example by using
(entity.isTemporaryID == NO)
.
but every iteration I've tried comes back with errors of the form
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath entity.isTemporaryID not found in entity <NSSQLEntity Cocktail id=4>'
How can one execute the equivalent of [[cocktail objectID] isTemporaryID]
in an NSPredicate
?