Generate scalar properties for primitive types #258
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a "scalars" boolean template variable for both the Objective-C and the Swift templates.
When true, property declarations for non-optional attributes with hasScalarAttributeType will use the appropriate scalar type and, in the case of Objective-C, omit the generated *Value accessors.
Additionally (when scalars=false), generated NSNumber properties for hasScalarAttributeType attributes in the Swift template will only be optional when the attribute is optional, just as it is for Strings or NSDate etc (if that's contentious then let me know, I just don't know of a reason why NSNumber should be any different).
This change may go some way to easing the pain described in #219, but Swift *Value accessors are a separate issue that probably still needs to be addressed.
Compatibility: Core Data support for scalar properties appeared in iOS 5 and OS X 10.7, though my own testing is limited to iOS 8 and 10.10.