Question

I have two entities correlated (E1,E2) with a one to many relationship E1 <--->> E2 (relationship name: pictures)

E1 also has other relationships one to many with different Entities (E3,E4)

When I retrieve the E1 from coredata E1.pictures result:

pictures = "<relationship fault: 0x1d5a8c60 'pictures'>";

Now,

  • I know that this kind of message is not an error :)
  • E1.pictures is not empty.
  • When I save a new picture and I provide to refresh the E1 managed object ( [E1.managedObjectContext refreshObject:E1 mergeChanges:YES]; ) the E1.pictures is returned back correctly and I can show the images.
  • I try to make the refreshObject:E1 before to take the count, but it doesn't work

I assume that I retrieved the object correctly. I would like to know before save a new picture how many pictures have the E1 and obviously show the pictures (but without a picture count... I don't go anywhere)

Could I be missing something? Can somebody help me?

Was it helpful?

Solution

Take a look at this: Core Data Faulting and Uniquing

The word 'fault' in Core Data essentially just means that the object of the relationship has not been fetched yet. If you access the pictures property of your E1 instance, the fault will be fired and you will see the E2object.

Also, calling refresh on a Core Data object will set it's relationships back to faults, which is why you are seeing that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top