Retired Document
Important:
The information in this document is deprecated in Mac OS X v10.7; don't use it for new development. Instead use the iCloud extensions to the NSFileManager
class to share file-based data and use the NSUbiquitousKeyValueStore
class to share preferences. Use the Address Book framework to access shared contact data and use the Calendar Store framework to access shared calendar data.
Debugging Multiple Clients
The sync engine supports multiple sync clients joining the same sync session. That is, when one client begins a sync session, other clients that sync the same entities can optionally join the sync session. All the information on multiple clients—for example, which records each client pushes and pulls in the sync session—is available in Syncrospector. You can also compare the call history of each client and view other details in the truth database.
Read Managing Your Sync Session to understand the phases and sequence of methods called during a sync session.
Download the SimpleStickies and StickiesWithCoreData sample code projects to follow along in this chapter.
Displaying Data Change Alerts
It’s useful to turn on data change alerts when you debug multiple clients. A data change alert is the window that appears to users during a sync session confirming whether or not a set of changes should be applied. Normally, data change alerts appear for MobileMe and device clients only. However, using Syncrospector, you can turn on data change alerts for all clients. The data change alerts appear just before the pulling phase of a sync session.
Follow these steps to turn on data change alerts:
Launch Syncrospector.
Choose Preferences from the Syncrospector menu to open Preferences.
Select the “Always show Data Change Alert for all client types” option, as shown in Figure 7-1.
You can optionally set the threshold for when data change alerts appear by choosing a percentage from the Data Change Alert Threshold pop-up menu. For example, if you choose “more than 25%”, then a data change alert appears only when more than 25% of the total records change. If you are debugging your clients, set the threshold to “any.”
Viewing the Session History of Multiple Clients
To view the history of multiple clients in the same sync session, launch clients that not only use the same scheme but sync the same entities. At least one client needs to be configured to sync when other clients sync. For example, both SimpleStickies and StickiesWithCoreData sync only when you save local records but they both join other sync sessions. If you turn on data change alerts as described in Displaying Data Change Alerts and save the call history as described in Viewing the Call History, then you get a clear picture of what happens when multiple clients sync. Specifically turn on the call history of sync clients to see more details as described in Viewing the Client Call History.
Then follow these steps to view the results of two clients syncing together:
Build and launch the SimpleStickies and StickiesWithCoreData sample projects or other clients that sync together.
StickiesUsingCoreData syncs at startup so you don’t need to save local records to start the sync session.
If data change alerts are turned on as described in Displaying Data Change Alerts, alerts appear in each application before the changes are applied, as show in Figure 7-2. Verify that the data change alert shows the correct changes and click “Sync Stickies” (where “Stickies” is the localized data class display name defined in the schema).
You should now see a sticky window appear for each Note record you created using SimpleStickies. (Move the windows in StickiesUsingCoreData to see them all.)
After the clients sync, launch Syncrospector and choose Clients from the left-side pop-up menu.
Both clients should now appear in the table below the toolbar.
Next choose History from the left-side pop-up menu.
All of the sync sessions are displayed in the table below chronologically.
Click the carat in the Generation column of the last sync session to reveal the clients.
You should see SimpleStickies and StickiesWithCoreData listed in the Client column.
Follow the instruction in Viewing the Client Call History for each client to view both client call histories in separate windows.
Viewing Sync Plans in Action
You can also view the sync plans of multiple clients during a sync session. The sync plans list the participants and entities each client tells the sync engine it wants to sync during the negotiation phase.
Using Syncrospector, select Show Sync Plans from the Window menu.
Again, modify some records using one client and sync it to push the changes.
If a sync alert appears in the second client, click “Sync <data class display name>” to continue.
View the sync plans in the Sync Server window in Syncrospector by selecting the last sync session in the table below the toolbar when the status changes to “done.”
Both clients should be listed in the Participants column in the detail view. The Entities column should show the entities each client synced, as shown in Figure 7-3.
Copyright © 2011 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2011-07-06