• 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: (Inverse) relationship lost after being set properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (Inverse) relationship lost after being set properly


  • Subject: Re: (Inverse) relationship lost after being set properly
  • From: mmalcolm crawford <email@hidden>
  • Date: Sat, 25 Jun 2005 00:53:49 -0700


On Jun 24, 2005, at 7:17 PM, Doug Knowles wrote:

Found it. In moving managed objects from one "owner" to another, I
was simply adding the item to the new owner's mutable set
(representing the to-many relationship), without removing it from the
old owner's set. As a result, when I deleted the former owner, Core
Data thought the objects still belonged to it, and nullified the
inverse (to-one) relationship, as specified by my model.
The correct behavior (at least what's working for me now) is to remove
the object from the old owner's set before adding it to the new owner;
something like:
oldOwnersSet = [oldOwner mutableSetValueForKey:@"myToManyRelationship"];
newOwnersSet = [newOwner mutableSetValueForKey:@"myToManyRelationship"];
[oldOwnersSet removeObject:objBeingMoved]; // I was omitting this <<<<<<<<<<<
[newOwnersSet addObject:objBeingMoved];



In general there should be no need to do this -- see "Managing Relationships" at <http://developer.apple.com/documentation/Cocoa/ Conceptual/CoreData/Articles/cdLifecycleManagement.html#//apple_ref/ doc/uid/TP40001652-207874-TPXREF149>.


What other steps are you taking? What objects are you deleting when? How is your model defined?

mmalc

_______________________________________________
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


References: 
 >(Inverse) relationship lost after being set properly (From: Doug Knowles <email@hidden>)
 >Re: (Inverse) relationship lost after being set properly (From: Doug Knowles <email@hidden>)

  • Prev by Date: OutlineView manual update with bindings
  • Next by Date: Re: Core Data: Changing Transient Keys Dirties Database?
  • Previous by thread: Re: (Inverse) relationship lost after being set properly
  • Next by thread: Formatter questions
  • Index(es):
    • Date
    • Thread