Re: Added object to MOC, why isn't this a bug?
Re: Added object to MOC, why isn't this a bug?
- Subject: Re: Added object to MOC, why isn't this a bug?
- From: "Bobby B" <email@hidden>
- Date: Thu, 1 Jun 2006 17:33:49 -0400
Hi Chris!
Thank you for this. I didn't realize that the mutable set it returned
was tracked, I thought I would have to reset the values.
So in the below, when I add the newAlbum, which is a duplicate, what
is CoreData doing behind the scenes that prevents it from adding a
duplicate?
Thank you so much
Bobby
> // Why isn't this a bug? It's adding the object, which already
> exists in
> // the set. It should have two copies of it now, but it only
> // shows one, whicih is the updated and correct one.
> [currentAlbumsForArtist addObject:newAlbum];
> [newArtist setValue: currentAlbumsForArtist forKey:@"albums"];
It's not a bug because sets don't contain duplicates. Your
"newAlbum" isn't actually a new album; it's still the same album, it
just has an additional song in it. And just as above, you don't need
to set the artist's "albums" relationship again, because by
manipulating the mutable set that you got back from -
mutableSetValueForKey: you're actually manipulating the relationship.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden