From e11ffaf75f6ea2ed12e24a1497f3328cf3fb5046 Mon Sep 17 00:00:00 2001
From: Daniel Tull
Date: Sun, 2 Dec 2012 10:31:38 +0000
Subject: [PATCH] Implement ordered set accessors, as the Apple generated ones
crash
---
templates/machine.h.motemplate | 4 ++--
templates/machine.m.motemplate | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/templates/machine.h.motemplate b/templates/machine.h.motemplate
index 33b2e61c..adf5d23a 100644
--- a/templates/machine.h.motemplate
+++ b/templates/machine.h.motemplate
@@ -92,14 +92,14 @@ extern const struct <$managedObjectClassName$>FetchedProperties {<$foreach Fetch
<$endif$>
@end
-@interface _<$managedObjectClassName$> (CoreDataGeneratedAccessors)
<$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$>
+@interface _<$managedObjectClassName$> (<$Relationship.name.initialCapitalString$>CoreDataGeneratedAccessors)
- (void)add<$Relationship.name.initialCapitalString$>:(<$Relationship.immutableCollectionClassName$>*)value_;
- (void)remove<$Relationship.name.initialCapitalString$>:(<$Relationship.immutableCollectionClassName$>*)value_;
- (void)add<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_;
- (void)remove<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_;
-<$endif$><$endforeach do$>
@end
+<$endif$><$endforeach do$>
@interface _<$managedObjectClassName$> (CoreDataGeneratedPrimitiveAccessors)
<$foreach Attribute noninheritedAttributes do$>
diff --git a/templates/machine.m.motemplate b/templates/machine.m.motemplate
index a4ddc399..9bd71315 100644
--- a/templates/machine.m.motemplate
+++ b/templates/machine.m.motemplate
@@ -214,3 +214,22 @@ const struct <$managedObjectClassName$>FetchedProperties <$managedObjectClassNam
#endif
<$endif$>
@end
+
+<$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$><$if Relationship.jr_isOrdered$>
+@implementation _<$managedObjectClassName$> (<$Relationship.name.initialCapitalString$>CoreDataGeneratedAccessors)
+- (void)add<$Relationship.name.initialCapitalString$>:(<$Relationship.immutableCollectionClassName$>*)value_ {
+ [self.<$Relationship.name$>Set unionOrderedSet:value_];
+}
+- (void)remove<$Relationship.name.initialCapitalString$>:(<$Relationship.immutableCollectionClassName$>*)value_ {
+ [self.<$Relationship.name$>Set minusOrderedSet:value_];
+}
+- (void)add<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_ {
+ [self.<$Relationship.name$>Set addObject:value_];
+}
+- (void)remove<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_ {
+ [self.<$Relationship.name$>Set removeObject:value_];
+}
+@end
+<$endif$><$endif$><$endforeach do$>
+
+