Skip to content

Commit

Permalink
Fix: treat non-existant XML attributes correctly
Browse files Browse the repository at this point in the history
Xcode omits the optional attribute in its XML model output if
it is set to not-optional, but `NSPropertyDescription.optional`
defaults to YES.
To be on the safe side I decided to treat all Booleans the same.
Currenlty only optional was affected, because it's the only
attribute which default is YES.

That should fix issue #286
  • Loading branch information
mattbauch authored and Mikolaj Kalinowski committed Nov 20, 2015
1 parent f60bf94 commit a04b88d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions momcom/NSPropertyDescription+momcom.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode
}

NSPropertyDescription *propertyDescription = [[self alloc] init];
BOOL optional = NO;
BOOL transient = NO;
BOOL indexed = NO;
BOOL syncable = NO;

for (NSXMLNode *xmlAttribute in [xmlNode attributes]) {
Expand All @@ -27,11 +30,11 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode
if ([attributeName isEqualToString:@"name"]) {
[propertyDescription setName:attributeString];
} else if ([attributeName isEqualToString:@"optional"]) {
[propertyDescription setOptional:[attributeString isEqualToString:@"YES"]];
optional = [attributeString isEqualToString:@"YES"];
} else if ([attributeName isEqualToString:@"transient"]) {
[propertyDescription setTransient:[attributeString isEqualToString:@"YES"]];
transient = [attributeString isEqualToString:@"YES"];
} else if ([attributeName isEqualToString:@"indexed"]) {
[propertyDescription setIndexed:[attributeString isEqualToString:@"YES"]];
indexed = [attributeString isEqualToString:@"YES"];
} else if ([attributeName isEqualToString:@"syncable"]) {
syncable = [attributeString isEqualToString:@"YES"];
} else if ([attributeName isEqualToString:@"versionHashModifier"]) {
Expand All @@ -40,6 +43,11 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode
[propertyDescription setRenamingIdentifier:attributeString];
}
}

[propertyDescription setOptional:optional];
[propertyDescription setTransient:transient];
[propertyDescription setIndexed:indexed];


NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];

Expand Down

0 comments on commit a04b88d

Please sign in to comment.