I\'ve read Subclassing NSManagedObject with swift 3 and Xcode 8 beta and read this great tutorial. Still have questions on some points.
To address each of your notes and considering the cases where codegen is set to Manual/None
and Category/Extension
:
Category/Extension
case, the relevant changes will be made automatically. In the Manual/None
case, you can either manually update the Extension (or the class file) or you can redo the "create NSManagedObject subclass" which will update the Extension with the amended attribute details. If you do not do this, Xcode will not recognise the new attribute details and will not provide code completion for them (nor will it successfully compile if you try to override code completion). But unlike what you think this has nothing to do with the properties being marked as @NSManaged
.Category/Extension
just create and tailor the class file as you require.Category/Extension
the properties are declared in the automatically created Extension file in Derived Data.Manual/None
case because the Extension file in Derived Data is overwritten with each new build so any changes are lost.As to your final point: you cannot arbitrarily change the type of the property definition: the type specified in the model editor must correspond to the type specified in the property definition. You can switch between optional and non-optional versions of the same type, and you can switch between Date and NSDate etc, but switching from Date to String will not work. I suspect you are correct that this is due to the bridging between Swift value type and the corresponding Objective-C reference type using as
. See here.