Objective c - Core Data saving approach

前端 未结 3 1305
伪装坚强ぢ
伪装坚强ぢ 2021-01-28 12:38

I have some NSManagedObject subclass in my app, and I\'m trying to understand when and how to save changes.
I will try to explain myself, for example class

3条回答
  •  情书的邮戳
    2021-01-28 13:26

    Depending on the amount of changes that you make and the volume of data that needs to be saved with each change, yo can choose to save a little or a lot. If you are just saving a string or a number or a bool, then go ahead and call save: on your context as soon as the changes were made.

    If it is a lot of data, you may want to coalasce your changes and then save it on a background queue so that you are not blocking the main queue. This way you are not waiting to go to the background to perform your saves.

    Tim

提交回复
热议问题