I have two entities. They are named SP and Code. I have 10 and 5 attributes in each respectively. I have inverse relationships on both the entities. I input the data into the model using the firefox addon sqlite manager. So I DID NOT WRITE a line like this
sp.coderelationship = codeObj; or code.sprelationship = spObj; anywhere in the code. Now in a viewcontroller i am retrieving data.
self.spArray = [self.managedObjectContext executeFetchRequest:fR error:&error];
for(SP *spObj in self.spArray)
{
NSLog(@"description is %@",spObj.sPDescription);
Code *codObj = spObj.coderelationship;
NSLog(@"it has value %@",codObj);
NSLog(@" unique name is %@",codObj.uniqueCodeName);
}
The output is correct for description. It prints a value “xyz”. But for the last 2 logs its null.
My Entities design
SP
-sPDescription
-sPName
-sPID
Relationship
-coderelationship
Code
-codeName
-codeID
-codeDate
Relationship
-sprelationship
If more information is needed let me know. Thanks..
Before executing the fetch request add this code:
Also, have you verified that the relationships have correctly been inserted into the db?