Can't set default value of string property to "" in the Xcode CoreData model designer
- by glenc
I have an entity in my datamodel with a string property that is currently optional, and I'd like to convert this property to a required property with a default value of the empty string.
As others have discovered, leaving the default value blank results in validation errors (since the designer interprets this as NULL), but trying '', "", or @"" as the default value results in those literal characters being interpreted as the default, rather than the empty zero-length string, as desired.
I did find this thread on Google, however, apart from the solution being really ugly (model definition split between the .xcdatamodel and objc source), it also doesn't work for lightweight migrations because those migrations are done solely based on the .xcdatamodel files and the objc logic from your entity implementations isn't loaded.
Is there any way to achieve this in the data model designer?