Explanation of NSIncrementalStore in plain english

后端 未结 3 682
终归单人心
终归单人心 2021-01-31 19:47

I\'ve been seeing NSIncrementalStore popping up as I\'ve been researching the best ways to interact with a web service using core data.

After reading an art

3条回答
  •  情书的邮戳
    2021-01-31 20:10

    In a nutshell, if you use the SQLite store with your Core Data you are already using an incremental store. All the benefits of incremental stores (i.e. mainly not having to load the entire store into memory) are already at your disposal.

    As for the concrete application of the NSIncrementalStore API, I would suggest that you first define exactly which problem you want to solve. If you require this API or not would be determined by the specific needs of your programming task.


    EDIT in response to question edit

    I would simply do it like this: In your Core Data entities on the device you can have an attribute BOOL uploaded. When the web service becomes available, start an upload and pull all the objects not uploaded yet.

    To upload, transform your objects into NSArray and NSDictionary, perhaps into JSON format and POST to your web site. When the web site responds that it saved the data, mark all the objects as uploaded.

提交回复
热议问题