Semantics of optional in the context of Transient Attributes in CoreData
Asked Answered
L

1

3

What difference does it make if a transient attribute in core data is set to optional or non optional.

Normally when you set an entity to being optional, it allows the entity owning that attribute to be stored with that attribute set to null. But in the case of transient attributes they aren't actually stored. So does setting a transient property to optional do anything?

Do you need to set a transient attribute to optional if it is calculated using an optional non-transient property?

Any insight is appreciated.

Lebbie answered 21/4, 2017 at 2:46 Comment(0)
L
1

If I don't set the transient attribute to optional I get the following error: Core Data Save Error (NSValidationErrorKey, Cocoa error 1570) which according to the following SO Q/A is an error you get when you try and store an entity with non-optional attributes set to Null.

If I set the attribute to optional this error does not occur. So it seems as though you need to set transient attributes to optional to let core data know that you don't need/want to store a value for the transient attribute

Lebbie answered 21/4, 2017 at 3:53 Comment(1)
Actually, the attribute inspector should not allow checkbox for selecting optionality for the transient property since it doesn't make any sense for it to be optional or non-optional. Did you find explanation in the Apple documentations?Redware

© 2022 - 2024 — McMap. All rights reserved.