当储蓄失败时,你(作为方案者)就错了。
我撰写了一些极为复杂的核心-Data申请,从来不看到生产中的失败。
保证用户能够进入这些数值,可以不发生任何错误。
This means if you have a not-optional relationship don t accept the "Done"-button until the user has selected an entity for this relationship. Or set a default relationship entity.
If you need a NSString in a special format validate that string before accepting it.
It s more convenient for the user too. If you tell him 10 minutes ago you did something wrong, thats why I will delete all your changes
he will think WTF?
. If you tell him The value you try to enter is not in the correct format. Please use xxxxx
he will think Ok, let s change it.
And now after you made sure that a save never fails you can put [context rollback]
in it, because you should never say never.
But before you do this you should ask the user if he wants to send you the error log. Because a save should never fail.