tags:

views:

31

answers:

1

I have an entity with an transient attribute, and it's optional flag is set to NO. If I fetch an instance of this entity from persistent store, change something and save back, need I set this transient attribute ?

+1  A: 

Transient values are not saved at all so optional or required has no effect on them.


Update:

Okay, I got that completely wrong. I am in the habit of setting default values and/or my transients always have calculated values so I'd forgotten that required transients do have to have a value. I tested it make sure.

If you have a transient attributes without values and its required the logic of the app should enforce that. Since you don't seem to use the transient every time, I suggest setting a default value or calculating the value in a custom getter method.

TechZen
but in my test, save will fail if leave required transient attribute nil.
gwang
Yes, I got that wrong. See the update.
TechZen
thank you. I also found that setting default value is a good way
gwang