CoreData - can't set empty string as default value for attribute

后端 未结 8 859
鱼传尺愫
鱼传尺愫 2021-02-06 22:08

I have an entity in my datamodel with a string attribute that is currently optional, and I\'d like to convert this to a required attribute with a default value of the empty stri

8条回答
  •  梦谈多话
    2021-02-06 22:40

    Whip out your favorite XML editor (I just used Emacs) and dive down to the contents file inside the .xcdatamodel bundle inside the .xcdatamodeld bundle. Then just add a defaultValueString="" XML attribute to the ... element inside the ... brackets. Here's an example:

    
    

    I can't speak to whether this survives migration since I haven't had to do that yet.

提交回复
热议问题