Batch error in many ways for a collection of objects

Scenario:

Let's say I have an object named Author that has a to-many relationship called books to a Book object (the inverse relationship of Author ). If I have an existing collection of Author objects, I want a crash regarding books for all of them in a single fetch request.

the code

This is what I have tried so far:

 NSArray *authors = ... // array of `Author` objects NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Book"]; fetchRequest.returnsObjectsAsFaults = NO; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"author IN %@", authors]; 

The execution of this query to the selection does not lead to the fact that the books relation of objects in the authors array is erroneous (checked by logging).

I also tried doing the fetch request differently:

 NSArray *authors = ... // array of `Author` objects NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Author"]; fetchRequest.returnsObjectsAsFaults = NO; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"SELF IN %@", authors]; fetchRequest.relationshipKeypathsForPrefetching = @[@"books"]; 

It also does not cause crashes. What is a suitable way to do this?

+8
objective-c core-data nsfetchrequest
source share

No one has answered this question yet.

See related questions:

10
Communication error with master data
nine
Master Data - NSPredicate to Filter Many Relationships
6
Retrieve communication objects
5
Does calling a "count" in relation to many CoreData-related relationships with all objects in the collection?
3
How to use Coredata ordered relationships with NSFetchedResultsController
3
Core Data - Get object-to-many identifiers without errors
2
NSPredicate Master Data with Multiple Relationships
2
How to fix an error for a managed entity relationship
one
What is the most efficient way to tune relationships between thousands of objects in Core Data?
0
How to filter objects one at a time in Core Data.

All Articles