Semantics of optional in the context of Transient Attributes in CoreData

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.

Answer1:

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

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Semantics of optional in the context of Transient Attributes in CoreData