Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your design is all needlessly complex and redundant. I think the relationship shows as nil because you've got the wrong class assigned to your <code>self.existingItem</code> property.</p> <p>Firstly, there is no reason to create another context just for another view on the same foreground thread. Just pass the existing context to the next view and save yourself the headache of merging to context for no functional reason.</p> <p>Secondly, this block:</p> <pre><code>}else{ self.existingItem = (Item *)[self.addEditContext objectWithID:[self.existingItem objectID]]; } </code></pre> <p>... is completely pointless because you are setting <code>self.existingItem</code> to itself. You might as well have written:</p> <pre><code>self.existingItem = self.existingItem; </code></pre> <p>... because object ids are fixed in the persistent store once an object as been saved. If the object hasn't been saved then the ID is temporary and the other context won't be able to find it anyway. </p> <p>The most likely cause of the problem is with the definition of the <code>existingItem</code> property. If you defined it as <code>id</code> or <code>NSManagedObject</code> then it won't respond to the the <code>title</code> selector and will return nil. It would error out but you've cast it as a <code>Item</code> so the compiler thinks it will respond to all the messages that an <code>Item</code> object would. </p> <p>Don't use cast unless you know you will be forcing an object to mimic another. Otherwise, you are just creating opportunities to hide errors from the compiler. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload