Sync master data between iOS devices over Wi-Fi?

I want to sync master data between iOS devices over Wi-Fi. I know how to establish a connection with ASyncSockets, but I'm not sure about the next step - synchronizing the master data.

I am aware of the ZSync project for syncing between iOS and Mac, but I was wondering if anyone knows if it is possible to do the same thing between iOS devices.

+3


source to share


2 answers


You can solve this in several ways, but I would consider one of these two:

  • Take properties of the subclass NSManagedObject

    , convert them to, NSData

    and use AsyncSocket to wrap them. Then, when the receiving application receives all the properties, it recreates the object in its own database.

  • Transfer the entire database at once. You don't need to recreate anything.

The first option has the advantage that it only sends what it needs. If you have thousands of objects and you change them, you only move one object. On the other hand, things can get very complicated if you have multiple relationships on the same object, since you will have to send related objects as well.



The second option is the easiest one for you, but it is not very effective. If you change one object, you are sending the entire database. If your database is several megabytes in size, this can take a while, and you do this every time you make a change.

Ideally, you do it the way iCloud does it. Move only those things that have changed. I don't know how iCloud does it, but I'm pretty sure it's not something trivial. Whichever method works best depends on how large your database is and how often objects change. Method 2 works best for a large, complex database with small changes, Method 1 if your database is relatively simple (no or few relationships) and undergoes large changes.

0


source


If you can navigate the web, I will definitely go with iCloud, which will handle it effectively for you. If your app is supposed to run on Wi-Fi only, you might be able to override the same iCloud behavior. How it works is described in Using Master Data with iCloud Programming Notes :



In iOS 5, Core Data includes enhancements to support efficient integration of SQLite storage with iCloud. The main new feature is that every change you commit to persistent storage is written to discrete transaction log files that are stored in iCloud, instead of storing the persistent storage file in the cloud directly. This means the iCloud propagation change is efficient (the alternative would be to push the entire SQLite file for each change).

0


source







All Articles