I am saving a managedObjectContext with certains objects, but not with all the relationships filled. I mean:
A —> B (the relationship is optional)
But what I am doing is inserting A in the context and then saving. When I retrieve A with nsfetchedresults controller and print with NSLog B fields, all the numbers are 0 and the strings (null) (all the fields are not initiated, obviously, but i can “access” them and i’ve not inserted B in any moment). So I cannot do this since the relationship is never null:
if(a.relationship == nil) {…}
Is that normal? I think the relationship between A and B will be null and therefore I can’t access any fields.
Thanks in advance.
Samui,
A to-one relationship is either nil or a valid pointer. You are probably seeing the results of nil messages (i.e. the result of invoking a method on a nil object). Have you logged each of the fields in A?
Andrew