• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Added object to MOC, why isn't this a bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Added object to MOC, why isn't this a bug?
      • From: Chris Hanson <email@hidden>
References: 
 >Added object to MOC, why isn't this a bug? (From: "Bobby B" <email@hidden>)
 >Re: Added object to MOC, why isn't this a bug? (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Added object to MOC, why isn't this a bug?
  • Next by Date: Re: Added object to MOC, why isn't this a bug?
  • Previous by thread: Re: Added object to MOC, why isn't this a bug?
  • Next by thread: Re: Added object to MOC, why isn't this a bug?
  • Index(es):
    • Date
    • Thread