Hello,
You should also insert your new object into the editing context:
[[mainObject editingContext] insertObject:newObject];
then your two lines...
I may add that it is a better practice to do the following when adding
the object
to the relationship:
[mainObject addObject:newObject
toBothSidesOfRelationshipWithKey:@"addresses"];
Like that, if you add a reverse relationship in the future, it will be
handled as well...
Hope this helps
Alexander Lamb
Apple Enterprise Software & Services
Geneva / Switzerland
Cengiz Kayay wrote:
>
> Hi all,
>
> All I am trying to insert an object through a relationship.
>
> >From the main table I have a one-to-many relationship.
> By using the 'addTo' I need to insert the row I want.
> But It simply does not. Any solution to this?
>
> For the main table, this is an update but it should insert the added
> object!!
>
> [mainObject addToAddresses:newObject];
> [[session theEditingContext] saveChanges];
>
> Thanks,
>
> Get Your Private, Free Email at http://www.hotmail.com