Syncing Your Data the Cocoa Way
Prior to the introduction of Sync Services, there was no consistent way to synchronize data between applications on OS X. To synchronize data with Apple’s Address Book, you had to use the framework provided and handle all the synchronization yourself. To sync with iCal, you had to manually parse the file yourself because there was no API or framework to access it. The same was true with any other application provided by Apple.
OS X Tiger changed all that in a dramatic way. There is now a consistent interface to synchronize data with Apple’s applications. Currently, only three applications are using this sync service, but more are sure to follow. As of this writing, only Address Book, iCal, and Safari’s bookmarks have been exposed to the sync service, but the framework is wide open and enables a developer to not only sync with these applications but to also add their own applications to the service and expose their own data for synchronization. What this means to the end user is that soon your RSS reader, mail application, and financial application can all take advantage of these Sync Services, and you can synchronize your data across machines whenever and wherever you need it. Imagine checking your RSS reader on your PDA and your desktop machine automatically, knowing what articles you have already read and what new feeds you have added. The possibilities are truly amazing.
What It Does
So what exactly does this sync service do? To put it simply, it keeps all the data available to it in sync. Under the hood, there is a "truth database" that is the final answer when it comes to deciding what data is up to date. Each application that wants to either share its data or look at another application’s data subscribes to this truth database. When the application needs to change some data, its application notifies the truth database that the data has changed, and the database is responsible for notifying any and all other applications, devices, or machines that are interested in that piece of data.
Therefore, when I make a change to a calendar in iCal, it will notify the truth database that I updated the calendar. Then if another application needs to know about my calendars, for example, it would have previously subscribed with the truth database and it will be notified of the change to the calendar. That other application can then update its own data to reflect those changes and possibly push additional changes to the truth database. Likewise, when I make a change to my To Do list on my PDA and then connect it to my Mac, Sync Services will receive those changes and update iCal. All without me having to worry about which data goes where.
If I also have a .Mac account, the truth database will upload those changes to the .Mac account. This enables any other computer that I have subscribed to .Mac to read those changes and update its own truth database. This allows for the syncing of iCal, Address Book, and Safari bookmarks between computers. Each computer checks the .Mac for any truth database updates for these (and other) applications and keeps itself up to date.
In addition to being able to sync data between computers, it is also possible to use the sync engine to sync data with other devices such as cell phones and PDAs. Sync services will recognize these devices and understands that they do not sync as often as an application would and then handles them appropriately.
The framework is designed to be very extensible. Developers can add their own application to the truth database and be able to synchronize that data between applications on the same computer and even across .Mac. The specification even calls for a "peer-to-peer" synchronization that is not currently implemented but should allow synchronization between computers without the need of .Mac.