Non-optional attributes of core data entity are being marked as optional in generated CoreDataProperties swift file

Originator:hamburgersandtoast
Number:rdar://22020804 Date Originated:7/27/2015
Status:Open Resolved:
Product:Developer Tools Product Version:7.0 beta 4 (7A165t)
Classification:Other Bug Reproducible:
 
Summary:
In swift, generated NSManagedObject subclass files are marking all attributes as optional regardless of whether they actually are or not.

Steps to Reproduce:
1. Create a New Project - Single View Application
2. Languages: Swift, Devices: iPhone
3. Use Core Data
4. Click on data model
5. Add an entity
6. Add an attribute, type String
7. Uncheck ‘Optional’
8. Create New file - Core Data - NSManagedObject subclass
9. Select the data model
10. Select the entity
11. Create
12. Open the Entity+CoreDataProperties.swift file

Expected Results:
The attribute’s type should be set to String (non-optional)

Actual Results:
The attribute’s type is set to String? (optional)

Version:
Xcode Version 7.0 beta 4 (7A165t) & OS X Version 10.10.4 (14E46)

Comments

Same problem, but the reverse is also true

I have three attributes on an entity in my model createDate: Date (NOT-optional - checkbox unchecked) entryText: String (NOT-optional - checkbox unchecked) entryCode: Integer16 (optional - checkbox checked)

Here is the code that is generated:

@NSManaged public var createDate: NSDate?    <- optional (wrong)
@NSManaged public var entryText: String?    <- optional (wrong)
@NSManaged public var entryCode: Int16     <- not-optional (wrong)

When I try to work around it and do the opposite of what I want, it still gets generated incorrectly

By tobyjmorgan at Jan. 27, 2017, 8:41 p.m. (reply...)

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!