From a04b88de5f872f4a3899de7716db2c9738b55a61 Mon Sep 17 00:00:00 2001 From: Matthias Bauch Date: Mon, 25 May 2015 01:52:45 +0200 Subject: [PATCH] Fix: treat non-existant XML attributes correctly 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 --- momcom/NSPropertyDescription+momcom.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/momcom/NSPropertyDescription+momcom.m b/momcom/NSPropertyDescription+momcom.m index 1e9841ca..30436d9d 100644 --- a/momcom/NSPropertyDescription+momcom.m +++ b/momcom/NSPropertyDescription+momcom.m @@ -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]) { @@ -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"]) { @@ -40,6 +43,11 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode [propertyDescription setRenamingIdentifier:attributeString]; } } + + [propertyDescription setOptional:optional]; + [propertyDescription setTransient:transient]; + [propertyDescription setIndexed:indexed]; + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];