How does Core Data codegen decide whether to make a property optional?Swift + CoreData: Cannot Automatically Set Optional Attribute On Generated NSManagedObject SubclassStoring optional NSNumber in Core DataCore Data - Optional attributes and performanceCoreData Swift and transient attribute gettersHow to compare entity identity in Core DataXcode NSManagedObject subclass contains optionals when they are marked as non-optionalCore Data Codegen fail in Xcode 8Swift - Core Data - codegen - Make the extension conform to a protocol?How to give a sorting predicate in Core data model editorCreating a calculated property in Core DataCalculated Properties based on properties of underlying Entities in Core Data

Why do compilers behave differently when static_cast(ing) a function to void*?

Why does the Sun have different day lengths, but not the gas giants?

Which one is correct as adjective “protruding” or “protruded”?

Do Legal Documents Require Signing In Standard Pen Colors?

Request info on 12/48v PSU

Should I outline or discovery write my stories?

Calculating Wattage for Resistor in High Frequency Application?

How should I respond when I lied about my education and the company finds out through background check?

Is it improper etiquette to ask your opponent what his/her rating is before the game?

When were female captains banned from Starfleet?

Is it possible to put a rectangle as background in the author section?

Pre-mixing cryogenic fuels and using only one fuel tank

Delivering sarcasm

250 Floor Tower

The Staircase of Paint

Is the U.S. Code copyrighted by the Government?

Is a bound state a stationary state?

I am looking for the correct translation of love for the phrase "in this sign love"

Closed-form expression for certain product

What was the exact wording from Ivanhoe of this advice on how to free yourself from slavery?

Longest common substring in linear time

What should you do if you miss a job interview (deliberately)?

Why do we read the Megillah by night and by day?

Is it possible to have a strip of cold climate in the middle of a planet?



How does Core Data codegen decide whether to make a property optional?


Swift + CoreData: Cannot Automatically Set Optional Attribute On Generated NSManagedObject SubclassStoring optional NSNumber in Core DataCore Data - Optional attributes and performanceCoreData Swift and transient attribute gettersHow to compare entity identity in Core DataXcode NSManagedObject subclass contains optionals when they are marked as non-optionalCore Data Codegen fail in Xcode 8Swift - Core Data - codegen - Make the extension conform to a protocol?How to give a sorting predicate in Core data model editorCreating a calculated property in Core DataCalculated Properties based on properties of underlying Entities in Core Data













3















I am working with Xcode 10 + Swift 4.2 on macOS 10.13.6 High Sierra. I have created a data model and I am letting Core Data automatically generate classes for the data model entities. For the most part this works as expected. However, I cannot figure out how to predict whether some properties in the generated classes are going to be Optional types; it does not appear to depend on whether the corresponding attributes were declared as "Optional" (i.e. "Optional" check box is checked in the description of the attribute). Can someone help me figure out how Xcode figures out whether to make a class property optional or not?



Here is a small example which I've derived from my project. I just replaced the project-specific names with made-up names, but everything else is the same. First here is an extract from the data model for the description of the Foo entity:



<entity name="Foo" representedClassName="Foo" parentEntity="FooParent" syncable="YES" codeGenerationType="class">
<attribute name="v1" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v2" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v3" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v4" optional="YES" attributeType="UUID" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v5" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="v6" toMany="YES" deletionRule="Nullify" destinationEntity="Bar"
inverseName="baz" inverseEntity="Bar" syncable="YES"/>
</entity>


As you can see, v1, v2, and v6 are not declared optional in the data model, while v3, v4, and v5 are declared optional. Here is the code that was generated, which I found in Foo+CoreDataProperties.swift somewhere under the Xcode/DerivedData folder for my project.



extension Foo 
@nonobjc public class func fetchRequest() -> NSFetchRequest<Foo>
return NSFetchRequest<Foo>(entityName: "Foo")


@NSManaged public var v1: Date?
@NSManaged public var v2: Bool
@NSManaged public var v3: Bool
@NSManaged public var v4: UUID?
@NSManaged public var v5: String?
@NSManaged public var v6: NSSet?




As you can see v2 and v3 are not optional, while v1, v4, v5, and v6 are optional, and that's a different assignment of optional/non-optional than what was seen in the data model.



Can someone help me understand how Core Data decides whether a generated class property should be optional or non-optional?



On the one hand, I find myself writing v!.something where I would hope that I can write v.something because v is non-optional in the data model, and therefore there will certainly be some value present (assuming Core Data is enforcing the non-optional attribute).



And on the other hand, I want to write let v = v ... for a property v which is optional in the data model, so there might or might not be a value present. Xcode is giving me an error about that construct, but I can't omit a test -- I already know that some instances of v will be absent. Attempting to work around by writing if v != nil v! fails -- Xcode gives an error about not being able to unwrap a non-optional value (and also a warning about comparing a non-optional to nil).



Thanks in advance for any light you can shed on this.



EDIT: For the last bit about a non-optional property corresponding to an optional attribute, I see that I can just omit the ! and write if v != nil v -- of course the warning about comparing non-optional to nil is still there, but the error goes away. So that's a workaround.










share|improve this question
























  • This may help: stackoverflow.com/questions/25485273/…

    – Mike Taverne
    Mar 2 at 5:42











  • @MikeTaverne Thanks for the link. My question is pretty much the same as that. For the record, I found the second, less voted answer to be more helpful: stackoverflow.com/a/43827209/871096

    – Robert Dodier
    Mar 4 at 18:08















3















I am working with Xcode 10 + Swift 4.2 on macOS 10.13.6 High Sierra. I have created a data model and I am letting Core Data automatically generate classes for the data model entities. For the most part this works as expected. However, I cannot figure out how to predict whether some properties in the generated classes are going to be Optional types; it does not appear to depend on whether the corresponding attributes were declared as "Optional" (i.e. "Optional" check box is checked in the description of the attribute). Can someone help me figure out how Xcode figures out whether to make a class property optional or not?



Here is a small example which I've derived from my project. I just replaced the project-specific names with made-up names, but everything else is the same. First here is an extract from the data model for the description of the Foo entity:



<entity name="Foo" representedClassName="Foo" parentEntity="FooParent" syncable="YES" codeGenerationType="class">
<attribute name="v1" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v2" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v3" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v4" optional="YES" attributeType="UUID" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v5" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="v6" toMany="YES" deletionRule="Nullify" destinationEntity="Bar"
inverseName="baz" inverseEntity="Bar" syncable="YES"/>
</entity>


As you can see, v1, v2, and v6 are not declared optional in the data model, while v3, v4, and v5 are declared optional. Here is the code that was generated, which I found in Foo+CoreDataProperties.swift somewhere under the Xcode/DerivedData folder for my project.



extension Foo 
@nonobjc public class func fetchRequest() -> NSFetchRequest<Foo>
return NSFetchRequest<Foo>(entityName: "Foo")


@NSManaged public var v1: Date?
@NSManaged public var v2: Bool
@NSManaged public var v3: Bool
@NSManaged public var v4: UUID?
@NSManaged public var v5: String?
@NSManaged public var v6: NSSet?




As you can see v2 and v3 are not optional, while v1, v4, v5, and v6 are optional, and that's a different assignment of optional/non-optional than what was seen in the data model.



Can someone help me understand how Core Data decides whether a generated class property should be optional or non-optional?



On the one hand, I find myself writing v!.something where I would hope that I can write v.something because v is non-optional in the data model, and therefore there will certainly be some value present (assuming Core Data is enforcing the non-optional attribute).



And on the other hand, I want to write let v = v ... for a property v which is optional in the data model, so there might or might not be a value present. Xcode is giving me an error about that construct, but I can't omit a test -- I already know that some instances of v will be absent. Attempting to work around by writing if v != nil v! fails -- Xcode gives an error about not being able to unwrap a non-optional value (and also a warning about comparing a non-optional to nil).



Thanks in advance for any light you can shed on this.



EDIT: For the last bit about a non-optional property corresponding to an optional attribute, I see that I can just omit the ! and write if v != nil v -- of course the warning about comparing non-optional to nil is still there, but the error goes away. So that's a workaround.










share|improve this question
























  • This may help: stackoverflow.com/questions/25485273/…

    – Mike Taverne
    Mar 2 at 5:42











  • @MikeTaverne Thanks for the link. My question is pretty much the same as that. For the record, I found the second, less voted answer to be more helpful: stackoverflow.com/a/43827209/871096

    – Robert Dodier
    Mar 4 at 18:08













3












3








3








I am working with Xcode 10 + Swift 4.2 on macOS 10.13.6 High Sierra. I have created a data model and I am letting Core Data automatically generate classes for the data model entities. For the most part this works as expected. However, I cannot figure out how to predict whether some properties in the generated classes are going to be Optional types; it does not appear to depend on whether the corresponding attributes were declared as "Optional" (i.e. "Optional" check box is checked in the description of the attribute). Can someone help me figure out how Xcode figures out whether to make a class property optional or not?



Here is a small example which I've derived from my project. I just replaced the project-specific names with made-up names, but everything else is the same. First here is an extract from the data model for the description of the Foo entity:



<entity name="Foo" representedClassName="Foo" parentEntity="FooParent" syncable="YES" codeGenerationType="class">
<attribute name="v1" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v2" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v3" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v4" optional="YES" attributeType="UUID" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v5" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="v6" toMany="YES" deletionRule="Nullify" destinationEntity="Bar"
inverseName="baz" inverseEntity="Bar" syncable="YES"/>
</entity>


As you can see, v1, v2, and v6 are not declared optional in the data model, while v3, v4, and v5 are declared optional. Here is the code that was generated, which I found in Foo+CoreDataProperties.swift somewhere under the Xcode/DerivedData folder for my project.



extension Foo 
@nonobjc public class func fetchRequest() -> NSFetchRequest<Foo>
return NSFetchRequest<Foo>(entityName: "Foo")


@NSManaged public var v1: Date?
@NSManaged public var v2: Bool
@NSManaged public var v3: Bool
@NSManaged public var v4: UUID?
@NSManaged public var v5: String?
@NSManaged public var v6: NSSet?




As you can see v2 and v3 are not optional, while v1, v4, v5, and v6 are optional, and that's a different assignment of optional/non-optional than what was seen in the data model.



Can someone help me understand how Core Data decides whether a generated class property should be optional or non-optional?



On the one hand, I find myself writing v!.something where I would hope that I can write v.something because v is non-optional in the data model, and therefore there will certainly be some value present (assuming Core Data is enforcing the non-optional attribute).



And on the other hand, I want to write let v = v ... for a property v which is optional in the data model, so there might or might not be a value present. Xcode is giving me an error about that construct, but I can't omit a test -- I already know that some instances of v will be absent. Attempting to work around by writing if v != nil v! fails -- Xcode gives an error about not being able to unwrap a non-optional value (and also a warning about comparing a non-optional to nil).



Thanks in advance for any light you can shed on this.



EDIT: For the last bit about a non-optional property corresponding to an optional attribute, I see that I can just omit the ! and write if v != nil v -- of course the warning about comparing non-optional to nil is still there, but the error goes away. So that's a workaround.










share|improve this question
















I am working with Xcode 10 + Swift 4.2 on macOS 10.13.6 High Sierra. I have created a data model and I am letting Core Data automatically generate classes for the data model entities. For the most part this works as expected. However, I cannot figure out how to predict whether some properties in the generated classes are going to be Optional types; it does not appear to depend on whether the corresponding attributes were declared as "Optional" (i.e. "Optional" check box is checked in the description of the attribute). Can someone help me figure out how Xcode figures out whether to make a class property optional or not?



Here is a small example which I've derived from my project. I just replaced the project-specific names with made-up names, but everything else is the same. First here is an extract from the data model for the description of the Foo entity:



<entity name="Foo" representedClassName="Foo" parentEntity="FooParent" syncable="YES" codeGenerationType="class">
<attribute name="v1" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v2" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v3" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
<attribute name="v4" optional="YES" attributeType="UUID" usesScalarValueType="NO" syncable="YES"/>
<attribute name="v5" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="v6" toMany="YES" deletionRule="Nullify" destinationEntity="Bar"
inverseName="baz" inverseEntity="Bar" syncable="YES"/>
</entity>


As you can see, v1, v2, and v6 are not declared optional in the data model, while v3, v4, and v5 are declared optional. Here is the code that was generated, which I found in Foo+CoreDataProperties.swift somewhere under the Xcode/DerivedData folder for my project.



extension Foo 
@nonobjc public class func fetchRequest() -> NSFetchRequest<Foo>
return NSFetchRequest<Foo>(entityName: "Foo")


@NSManaged public var v1: Date?
@NSManaged public var v2: Bool
@NSManaged public var v3: Bool
@NSManaged public var v4: UUID?
@NSManaged public var v5: String?
@NSManaged public var v6: NSSet?




As you can see v2 and v3 are not optional, while v1, v4, v5, and v6 are optional, and that's a different assignment of optional/non-optional than what was seen in the data model.



Can someone help me understand how Core Data decides whether a generated class property should be optional or non-optional?



On the one hand, I find myself writing v!.something where I would hope that I can write v.something because v is non-optional in the data model, and therefore there will certainly be some value present (assuming Core Data is enforcing the non-optional attribute).



And on the other hand, I want to write let v = v ... for a property v which is optional in the data model, so there might or might not be a value present. Xcode is giving me an error about that construct, but I can't omit a test -- I already know that some instances of v will be absent. Attempting to work around by writing if v != nil v! fails -- Xcode gives an error about not being able to unwrap a non-optional value (and also a warning about comparing a non-optional to nil).



Thanks in advance for any light you can shed on this.



EDIT: For the last bit about a non-optional property corresponding to an optional attribute, I see that I can just omit the ! and write if v != nil v -- of course the warning about comparing non-optional to nil is still there, but the error goes away. So that's a workaround.







swift xcode core-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 2 at 3:07







Robert Dodier

















asked Mar 2 at 2:58









Robert DodierRobert Dodier

11.4k11835




11.4k11835












  • This may help: stackoverflow.com/questions/25485273/…

    – Mike Taverne
    Mar 2 at 5:42











  • @MikeTaverne Thanks for the link. My question is pretty much the same as that. For the record, I found the second, less voted answer to be more helpful: stackoverflow.com/a/43827209/871096

    – Robert Dodier
    Mar 4 at 18:08

















  • This may help: stackoverflow.com/questions/25485273/…

    – Mike Taverne
    Mar 2 at 5:42











  • @MikeTaverne Thanks for the link. My question is pretty much the same as that. For the record, I found the second, less voted answer to be more helpful: stackoverflow.com/a/43827209/871096

    – Robert Dodier
    Mar 4 at 18:08
















This may help: stackoverflow.com/questions/25485273/…

– Mike Taverne
Mar 2 at 5:42





This may help: stackoverflow.com/questions/25485273/…

– Mike Taverne
Mar 2 at 5:42













@MikeTaverne Thanks for the link. My question is pretty much the same as that. For the record, I found the second, less voted answer to be more helpful: stackoverflow.com/a/43827209/871096

– Robert Dodier
Mar 4 at 18:08





@MikeTaverne Thanks for the link. My question is pretty much the same as that. For the record, I found the second, less voted answer to be more helpful: stackoverflow.com/a/43827209/871096

– Robert Dodier
Mar 4 at 18:08












2 Answers
2






active

oldest

votes


















1














Core Data is still rooted in Objective-C. So the primitives (bool, int, float, etc.) will be non-optionals, and the objects will be optionals.



Some data can be either an object or a primitive. For example, someone's age could be a NSNumber or a NSInteger. If you prefer that such a variable be backed by a primitive, then you can check the scalar box for the property in your model.






share|improve this answer
































    0














    I think you could look at attribute tab, there's optional="YES". It decided if that property is optional or not. You could changes by unchecked optional in Data Model insepector



    enter image description here






    share|improve this answer























    • Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

      – Robert Dodier
      Mar 3 at 1:20











    • May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

      – donmichael
      Mar 3 at 10:42










    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54954811%2fhow-does-core-data-codegen-decide-whether-to-make-a-property-optional%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Core Data is still rooted in Objective-C. So the primitives (bool, int, float, etc.) will be non-optionals, and the objects will be optionals.



    Some data can be either an object or a primitive. For example, someone's age could be a NSNumber or a NSInteger. If you prefer that such a variable be backed by a primitive, then you can check the scalar box for the property in your model.






    share|improve this answer





























      1














      Core Data is still rooted in Objective-C. So the primitives (bool, int, float, etc.) will be non-optionals, and the objects will be optionals.



      Some data can be either an object or a primitive. For example, someone's age could be a NSNumber or a NSInteger. If you prefer that such a variable be backed by a primitive, then you can check the scalar box for the property in your model.






      share|improve this answer



























        1












        1








        1







        Core Data is still rooted in Objective-C. So the primitives (bool, int, float, etc.) will be non-optionals, and the objects will be optionals.



        Some data can be either an object or a primitive. For example, someone's age could be a NSNumber or a NSInteger. If you prefer that such a variable be backed by a primitive, then you can check the scalar box for the property in your model.






        share|improve this answer















        Core Data is still rooted in Objective-C. So the primitives (bool, int, float, etc.) will be non-optionals, and the objects will be optionals.



        Some data can be either an object or a primitive. For example, someone's age could be a NSNumber or a NSInteger. If you prefer that such a variable be backed by a primitive, then you can check the scalar box for the property in your model.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 8 at 5:09

























        answered Mar 8 at 5:02









        Jeff WolskiJeff Wolski

        5,75242963




        5,75242963























            0














            I think you could look at attribute tab, there's optional="YES". It decided if that property is optional or not. You could changes by unchecked optional in Data Model insepector



            enter image description here






            share|improve this answer























            • Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

              – Robert Dodier
              Mar 3 at 1:20











            • May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

              – donmichael
              Mar 3 at 10:42















            0














            I think you could look at attribute tab, there's optional="YES". It decided if that property is optional or not. You could changes by unchecked optional in Data Model insepector



            enter image description here






            share|improve this answer























            • Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

              – Robert Dodier
              Mar 3 at 1:20











            • May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

              – donmichael
              Mar 3 at 10:42













            0












            0








            0







            I think you could look at attribute tab, there's optional="YES". It decided if that property is optional or not. You could changes by unchecked optional in Data Model insepector



            enter image description here






            share|improve this answer













            I think you could look at attribute tab, there's optional="YES". It decided if that property is optional or not. You could changes by unchecked optional in Data Model insepector



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 2 at 8:02









            donmichaeldonmichael

            18316




            18316












            • Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

              – Robert Dodier
              Mar 3 at 1:20











            • May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

              – donmichael
              Mar 3 at 10:42

















            • Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

              – Robert Dodier
              Mar 3 at 1:20











            • May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

              – donmichael
              Mar 3 at 10:42
















            Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

            – Robert Dodier
            Mar 3 at 1:20





            Thanks for your reply. Unfortunately whether the check box is checked does not determine whether the attribute is declared optional in the generated class, as you can see in the example with v1 (not optional in the data model but option in the class attribute), v2 (not optional in the data model and not optional in the class), and v3 (optional in the data model and not optional in the class).

            – Robert Dodier
            Mar 3 at 1:20













            May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

            – donmichael
            Mar 3 at 10:42





            May I suggest you manual generate Foo+CoreDataProperties.swift and remove the ? as you expected. It's should work correctly, this seems like a limitation.

            – donmichael
            Mar 3 at 10:42

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54954811%2fhow-does-core-data-codegen-decide-whether-to-make-a-property-optional%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme