1111#import " NSData+Base64.h"
1212#import " utils.h"
1313
14+ @interface MOMPrinter ()
15+
16+ @property (nonatomic , assign ) MOMPrinterPeropertiesOutputMode _mode;
17+
18+ @end
19+
1420@implementation MOMPrinter
1521
22+ #pragma mark - init methods
23+
24+ - (id )init {
25+ return [self initWithMode: MOMPrinterIncludeSuperclassProperties];
26+ }
27+
28+ - (id )initWithMode : (MOMPrinterPeropertiesOutputMode)mode {
29+
30+ self = [super init ];
31+ if (self) {
32+ self._mode = mode;
33+ }
34+ return self;
35+ }
36+
37+ #pragma mark -
38+
1639NSString *commonFlagsStringForProperty (NSPropertyDescription *property) {
1740 char ochar = [property isOptional ] ? ' O' : ' ' ;
1841 char tchar = [property isTransient ] ? ' T' : ' ' ;
@@ -119,7 +142,20 @@ - (BOOL)printPath:(NSString *)path {
119142 }
120143 [entityStr appendFormat: @" (%@ )" , [entity managedObjectClassName ]];
121144 NSPrintf (@" %@ \n " , entityStr);
122- NSMutableArray *properties = [NSMutableArray arrayWithArray: [entity properties ]];
145+
146+ NSMutableArray *properties = nil ;
147+
148+ if (self._mode == MOMPrinterIncludeSuperclassProperties) {
149+ properties = [NSMutableArray arrayWithArray: [entity properties ]];
150+ } else {
151+ // Filter out properties that belong to superclasses.
152+ NSSet *superentityProperties = [NSSet setWithArray: [superentity properties ]];
153+ NSMutableSet *entityProperties = [NSMutableSet setWithArray: [entity properties ]];
154+ [entityProperties minusSet: superentityProperties];
155+
156+ properties = [[entityProperties allObjects ] mutableCopy ];
157+ }
158+
123159 [properties sortUsingComparator: ^(id obj1, id obj2) {
124160 NSNumber *n1 = orderNumberForClassOfProperty (obj1);
125161 NSNumber *n2 = orderNumberForClassOfProperty (obj2);
@@ -130,6 +166,7 @@ - (BOOL)printPath:(NSString *)path {
130166 return result;
131167 }
132168 }];
169+
133170 for (id property in properties) {
134171 const char *name = [[property name ] UTF8String ];
135172 const char *commonFlags = [commonFlagsStringForProperty (property) UTF8String ];
0 commit comments