views:

113

answers:

1

I execute a core data fetch which specifies a predicate as follows:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"identifier IN %@", favoritesIDs];

When there are duplicate items in the favoriteIDs array, the fetch request only returns 1 managed object. How can I ensure that more than one instance is fetched? Thank you.

+3  A: 

Executing a fetch request on a context will never return more than one instance for any given managed object context; you would have to manage the number of virtual instance in some other fashion. In fact, any faulted object that you previously obtained from a context will result in the same instance of that object in later requests executed against the context (so you can end up with the same instance of an object even from multiple request executions).

Jason Coco
Note that this only applies when you are using a single `NSManagedObjectContext`. When you have more than one `NSManagedObjectContext`, such as in a multi-threaded environment, there is one instance per `NSManagedObjectContext`.
Marcus S. Zarra
@Marcus S. Zarra: I ment one instance per MO Context; of course managed object makes no sense in that context. Edited.
Jason Coco