Rafał Sroka
Rafał Sroka

Reputation: 40028

Will the default CoreData attribute value be set when the attribute is optional?

If the CoreData attribute is Optional, will the default value be set when the store is created? Or will it be left empty?

My checks on iOS 11 show that the default value gets set. However, I'm getting weird crash logs from devices running iOS 9 that make me think that this value is not set.

Documentation does not say anything about it. Do you guys know?

img

Upvotes: 3

Views: 1466

Answers (1)

Tom Harrington
Tom Harrington

Reputation: 70966

Default values are always set when you create a new instance of the entity.

If a value is optional, it's allowed to be nil. But if it has a default value, the initial value is not nil. You could make it nil later if you wanted, because it's optional. So the value might be nil but it won't start out that way.

Upvotes: 9

Related Questions