If I was creating an entity with a non-optional string attribute called, say, "name", I would put "Untitled" as the default. How could I localise this default value?
I could subclass the entity and and use NSLocalizedString
in awakeFromInsert
to do this. But I was wondering if there was another way.
Edit:
If this is the only way, then I'm fine with it. Just curious.
I think awakeFromInsert is the only way
You can try using -[NSEntityDescription attributesByName]. This will give you back an NSDictionary of NSAttributeDescription objects. You can then pull the one you want and use -[NSAttributeDescription setDefaultValue:] on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With