Skip to content

Commit cdd2641

Browse files
committed
Merge pull request rentzsch#150 from danielctull-forks/master
[FIX] Prevent empty structs if no attributes, relationships or fetched properties exist. Issue rentzsch#133. (Daniel Tull)
2 parents bd7f576 + 2de38d1 commit cdd2641

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

templates/machine.h.motemplate

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55
<$if hasCustomSuperentity$><$if hasSuperentity$>#import "<$customSuperentity$>.h"
66
<$else$><$if hasCustomBaseCaseImport$>#import <$baseClassImport$><$else$>#import "<$customSuperentity$>.h"<$endif$><$endif$><$endif$>
77

8+
<$if noninheritedAttributes.@count > 0$>
89
extern const struct <$managedObjectClassName$>Attributes {<$foreach Attribute noninheritedAttributes do$>
910
<$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Attribute.name$>;<$endforeach do$>
1011
} <$managedObjectClassName$>Attributes;
12+
<$endif$>
1113

14+
<$if noninheritedRelationships.@count > 0$>
1215
extern const struct <$managedObjectClassName$>Relationships {<$foreach Relationship noninheritedRelationships do$>
1316
<$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Relationship.name$>;<$endforeach do$>
1417
} <$managedObjectClassName$>Relationships;
18+
<$endif$>
1519

20+
<$if noninheritedFetchedProperties.@count > 0$>
1621
extern const struct <$managedObjectClassName$>FetchedProperties {<$foreach FetchedProperty noninheritedFetchedProperties do$>
1722
<$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$FetchedProperty.name$>;<$endforeach do$>
1823
} <$managedObjectClassName$>FetchedProperties;
24+
<$endif$>
1925

2026
<$foreach Relationship noninheritedRelationships do$>@class <$Relationship.destinationEntity.managedObjectClassName$>;
2127
<$endforeach do$>
@@ -26,7 +32,7 @@ extern const struct <$managedObjectClassName$>FetchedProperties {<$foreach Fetch
2632
<$endforeach do$>
2733
<$else$>@class <$Attribute.objectAttributeClassName$>;<$endif$><$endif$>
2834
<$endforeach do$>
29-
@interface <$managedObjectClassName$>ID : NSManagedObjectID {}
35+
@interface <$managedObjectClassName$>ID : <$if hasSuperentity$><$customSuperentity$>ID<$else$>NSManagedObjectID<$endif$> {}
3036
@end
3137

3238
@interface _<$managedObjectClassName$> : <$customSuperentity$> {}

templates/machine.m.motemplate

+6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33

44
#import "_<$managedObjectClassName$>.h"
55

6+
<$if noninheritedAttributes.@count > 0$>
67
const struct <$managedObjectClassName$>Attributes <$managedObjectClassName$>Attributes = {<$foreach Attribute noninheritedAttributes do$>
78
.<$Attribute.name$> = @"<$Attribute.name$>",<$endforeach do$>
89
};
10+
<$endif$>
911

12+
<$if noninheritedRelationships.@count > 0$>
1013
const struct <$managedObjectClassName$>Relationships <$managedObjectClassName$>Relationships = {<$foreach Relationship noninheritedRelationships do$>
1114
.<$Relationship.name$> = @"<$Relationship.name$>",<$endforeach do$>
1215
};
16+
<$endif$>
1317

18+
<$if noninheritedFetchedProperties.@count > 0$>
1419
const struct <$managedObjectClassName$>FetchedProperties <$managedObjectClassName$>FetchedProperties = {<$foreach FetchedProperty noninheritedFetchedProperties do$>
1520
.<$FetchedProperty.name$> = @"<$FetchedProperty.name$>",<$endforeach do$>
1621
};
22+
<$endif$>
1723

1824
@implementation <$managedObjectClassName$>ID
1925
@end

0 commit comments

Comments
 (0)