Problem Solved

As an update to my previous question... I'm an idiot. I forgot to actually connect my two objects. They were created, but not actually "connected."

--- Artificially Quoted.. ---

Hello, again!

Ok, my new problem deals with a very simple object graph that isn't
propagating deletes as I expect.  Here's the simplified setup:

Entity: Map
has a to-many relationship "rooms" to entity Room -- delete rule Cascade

Entity: Room
has a to-one relationship "map" to entity Map -- delete rule Nullify

These relationships are setup as inverses of each other.

My expectation is that if I delete a map entity, it will also delete
all rooms objects it references.

Now here's my test code:

- (void) testMapRoomCascade
{
    NSError *error = nil;

    [self createMapAndRoom1];
    NSArray *allRooms = [map allRooms: &error];
    int nRooms = [allRooms count];
    STAssertEquals( 1, nRooms, @"Map should have 1 room after
creating map and room." );

    NSArray *allMaps = [map allMaps: &error];
    [map delete: [allMaps objectAtIndex: 0]];

    int nMaps = [[map allMaps: &error] count];
    STAssertEquals( 0, nMaps, @"Map should have 0 maps after map
deletion." );

    allRooms = [map allRooms: &error];
    nRooms = [allRooms count];
    STAssertEquals( 0, nRooms, @"Map should have 0 rooms after map
deletion due to cascade delete rule." );   // <--- This is the error,
since nRooms is still 1!
}

--
Wil Hunt

"Life is the art of drawing sufficient conclusions from insufficient premises."
     -- Samuel Butler


On Mar 12, 2008, at 7:13 PM, [EMAIL PROTECTED] wrote:

Core Data - Cascading Not Working? (William Hunt)

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to