Xcode Core Data Automatic Code Generation Doesn't Respect "Optional" Flag

Originator:rileytestut
Number:rdar://27512940 Date Originated:23-Jul-2016 06:01 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 8
Classification:Other Bug Reproducible:Always
 
Summary:
When configuring Core Data entity attributes, you are able to specify whether an attribute is optional or not. Unfortunately, the generated swift files do not take this into account, and all generated attributes are marked as optional.

Steps to Reproduce:
1) Add an optional attribute to an entity
2) Generate the code

Expected Results:
Optional properties are declared as Swift optionals. Non-optional properties are _not_ declared as Swift optionals.

Actual Results:
All properties are declared as Swift optionals.

Regression:
n/a

Notes:
This may be intentional as it is possible to read from a value before it has ever been set. However, an alternative approach then would be to mark such properties as implicitly-unwrapped-optionals, which allow them to be used as normal, but hinting to the user that it might contain nil if being read before being written to.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!