The problem is, you need to do the insertions into the editing  
context BEFORE you try to set up any relationships between the  
objects.

Changing these lines:

    [theAddress addObject:newObject
toPropertyWithKey:@"toContactAddress"];
    theEditingContext = [[self session] defaultEditingContext];

    [theEditingContext insertObject:theAddress];
    [theEditingContext insertObject:newObject];
    [theEditingContext saveChanges];

To this order:

    theEditingContext = [[self session] defaultEditingContext];
    [theEditingContext insertObject:theAddress];
    [theEditingContext insertObject:newObject];
    [theAddress addObject:newObject
toPropertyWithKey:@"toContactAddress"];
    [theEditingContext saveChanges];

Should fix your problem.

Hope this helps,
        --Greg

-----
Greg Titus
Omni Development Inc.
[EMAIL PROTECTED]

Reply via email to