Permalink
Browse files

Changing a value in a one-to-many on the one side will now remove sel…

…f from the inverse's many array - in my last commit, it did this only when changing to nil
  • Loading branch information...
1 parent 5508a79 commit 0d62ffb9545c265a9efdbeee03e90b41c1669cb8 Tyrone Trevorrow committed Aug 20, 2011
@@ -182,7 +182,7 @@
<$foreach Relationship noninheritedRelationships do$><$if ! Relationship.isToMany$>
- (void) set<$Relationship.name.initialCapitalString$>: (<$Relationship.destinationEntity.managedObjectClassName$>*) <$Relationship.name$>_ settingInverse: (BOOL) setInverse
{
- <$if Relationship.inverseRelationship$><$if Relationship.inverseRelationship.isToMany$>if (<$Relationship.name$>_ == nil && setInverse == YES) {
+ <$if Relationship.inverseRelationship$><$if Relationship.inverseRelationship.isToMany$>if ((<$Relationship.name$>_ == nil || ![<$Relationship.name$>_ isEqual: <$Relationship.name$>]) && setInverse == YES) {
[<$Relationship.name$> remove<$Relationship.inverseRelationship.name.initialCapitalString$>Object: (<$managedObjectClassName$>*)self settingInverse: NO];
}<$else$>if (<$Relationship.name$>_ == nil && setInverse == YES) {
[<$Relationship.name$> set<$Relationship.inverseRelationship.name.initialCapitalString$>: nil settingInverse: NO];
@@ -182,7 +182,7 @@
<$foreach Relationship noninheritedRelationships do$><$if ! Relationship.isToMany$>
- (void) set<$Relationship.name.initialCapitalString$>: (<$Relationship.destinationEntity.managedObjectClassName$>*) <$Relationship.name$>_ settingInverse: (BOOL) setInverse
{
- <$if Relationship.inverseRelationship$><$if Relationship.inverseRelationship.isToMany$>if (<$Relationship.name$>_ == nil) {
+ <$if Relationship.inverseRelationship$><$if Relationship.inverseRelationship.isToMany$>if ((<$Relationship.name$>_ == nil || ![<$Relationship.name$>_ isEqual: <$Relationship.name$>]) && setInverse == YES) {
[<$Relationship.name$> remove<$Relationship.inverseRelationship.name.initialCapitalString$>Object: (<$managedObjectClassName$>*)self settingInverse: NO];
}<$else$>if (<$Relationship.name$>_ == nil) {
[<$Relationship.name$> set<$Relationship.inverseRelationship.name.initialCapitalString$>: nil settingInverse: NO];

0 comments on commit 0d62ffb

Please sign in to comment.