Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propertyDescription.optional not set because XML attribute is not present #286

Closed
mattbauch opened this issue May 24, 2015 · 1 comment
Closed

Comments

@mattbauch
Copy link
Contributor

I was wondering why, after incorporating the changes of #245, my Swift machine files didn't use optionality correctly. So I did a couple of tests and I think I found a bug.

Currently mogenerator uses something like this to create NSPropertyDescription (and others) from the XML CoreData model:

// NSPropertyDescription+momcom.m:33

} else if ([attributeName isEqualToString:@"optional"]) {
    [propertyDescription setOptional:[attributeString isEqualToString:@"YES"]];
}

Unfortunately the Xcode model editor does not create an optional xml attribute if the core data attribute is not optional. So propertyDescription.optional is never set. So it is still set to its default value. Which in this case is YES, which is the exact opposite from what it should be.

mkalinowski pushed a commit to mkalinowski/mogenerator that referenced this issue Nov 20, 2015
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 rentzsch#286
rentzsch pushed a commit that referenced this issue Mar 3, 2016
If the scalarsWhenNonOptional template var is set to true, and an Attribute is not optional (requires fix for #286), then we'll generate accessor/mutator methods using the plain attribute name rather than with the Value suffix.
@justin
Copy link
Collaborator

justin commented Mar 22, 2016

We are declaring pull request and issue 0 now that 1.3 is out. If this is still an issue you'd like to see address with 1.30 and going forward, please open a new issue so we can start a fresh discussion. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants