Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data - How to check if an object relationship exists without firing a fault

There is an object A and an Object B. Object B has one attribute that is type transformable (image), and one relationship, which is to an object A. Object A may have a relationship to one, and only one, object B, or it may not.

As I enumerate through my object A array, I want to check if each object A has an object B. But, I don't want to fire the fault for object B (which would invoke the reverse imageToData NSValueTransformer). I just want to know if it is there or not. How can I do this without bringing object B into memory?

like image 264
SAHM Avatar asked Nov 16 '13 13:11

SAHM


1 Answers

I think you can just test

if (objectA.relationshipToB != nil) ...

This will not fire a fault for the related B object because you don't access its properties.

like image 115
Martin R Avatar answered Sep 30 '22 10:09

Martin R