Mark attribute as optional or not so generator mark it as Optional or not

Originator:tmk.szlc
Number:rdar://21785457 Date Originated:12 July 2015
Status:Open Resolved:
Product:Xcode Product Version:Xcode 7 beta 3
Classification:Feature Request Reproducible:Not applicable
 
Summary:
Xcode generates by default NSManagedObject subclasses and marks all properties as Optionals.
e.g.
var a: String?

I think it would be nice to have ability to mark it as optional value so we it could avoid removing those question marks manually every time when subclass is generated - Since we've got nonnull and nullable in Objective-C it could be also implemented for Objective-C language.

I would like to have generator which gives me extension looking like following:

extension Car {
    var wheelCount: NSNumber
    var doorCount: NSNumber
    var driver: Driver?
}

I don't know if this should be reported in another ticket but setting default value for attribute also does not cause that property will be non-optional.

I would like to set default value of wheelCount to 4 and it should cause that wheelCount will not be optional too.

Steps to Reproduce:
1. Create project with Core Data
2. Add entity with some attributes
3. Generate class for the entity
4. See that properties are Optionals.

Expected Results:
1. As a developer I would like to have ability to mark which properties are optionals and which are not. 
2. I also would like to set default value for property which should also mean that the property will be non-optional.

Actual Results:
Extension of entity class is generated with optional properties.

Version:
Xcode 7 beta 3, Project with deployment target set to 9.0

Notes:


Configuration:


Attachments:

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!