Search code examples
core-dataparse-platformafincrementalstore

AFIncrementalStore with Parse


I am developing an social app on iOS that have many-to-many relation, local persistency, and user interaction. I have tried using native Parse API in iOS and find it too cumbersome to do all the client-server logic. So my focus shifted to finding a syncing solution.

After some research I found AFIncrementalStore quite easy to use and it's highly integrated in CoreData. I just started to work on this and I have two questions to ask:

1) How to do the authentication process? Is it in AFRESTClient? 2) How to set up AFRESTClient to match Parse's REST API? (an example would be great!)

P.S. I also found FTASync, which seems to be another solution. Any thought on this framework?

Any general suggestion on client-server syncing solutions will be highly appreciated!

Thanks,

Lei Zhang


Solution

  • Take a look at this StackOverflow question and at Chris Wagner's article on raywenderlich.com.

    The linked SO question has examples for how to include the authentication token with each request to Parse. So you'll just need to have the user log in first, and store their token to include it with each subsequent request.

    Chris Wagner's tutorial has a sample AFHTTPClient named SDAFParseApiClient to communicate with the Parse REST API. You'd have to adapt it to be an AFRESTClient subclass, but it should give you a start.

    Some other thoughts between the two solutions you're considering:

    • AFIncrementalStore does not allow the user to make any changes without a network connection, while FTASync keeps a full Core Data SQLite store locally and syncs changes to the server when you tell it to.
    • FTASync requires you to make all your synched managed objects subclasses of FTASyncParent, with extra properties for sync metadata. AFIncrementalStore keeps its metadata behind the scenes, not in your model.
    • FTASync appears not to be widely used and hasn't been updated in over a year; if you use it you will likely be maintaining it.