Next Page > Hide TOC

NSPersistentStoreCoordinator Sync Services Additions Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/SyncServices.framework
Availability
Available in Mac OS X v10.5 and later.
Companion guide
Declared in
ISyncCoreData.h

Overview

This category adds support for syncing Core Data applications—that is, syncing local changes made to managed objects to corresponding records managed by the sync engine—records that may be shared with other applications and synced to other computers over .Mac.

Use the syncWithClient:inBackground:handler:error: method to start a sync either in the foreground or background. Optionally provide a sync handler that can intervene during the sync session. For example, verify changes before they are applied to local managed objects. The supplied sync handler must conform to the NSPersistentStoreCoordinatorSyncing protocol.

Read Syncing Core Data Applications in Sync Services Programming Guide for more details on using Core Data sync.

Tasks

Syncing

Instance Methods

setStoresFastSyncDetailsAtURL:forPersistentStore:

Specifies where to save details about fast syncing for a persistent store.

- (void)setStoresFastSyncDetailsAtURL:(NSURL *)url forPersistentStore:(NSPersistentStore *)store

Parameters
url

The location to store the information.

store

The persistent store that is syncing.

Discussion

In order to fast sync, the persistent store coordinator needs to store information about what entities to push in the next sync. Use this method to specify where, in the file system, to store information about a sync per persistent store. This method must be invoked before any of the persistent stores are changed. If one of the persistent stores are changed before this method is invoked, the persistent store coordinator slow syncs on the next sync.

Availability
Declared In
ISyncCoreData.h

syncWithClient:inBackground:handler:error:

Syncs managed objects, stored by the receiver, with the sync engine.

- (BOOL)syncWithClient:(ISyncClient *)client inBackground:(BOOL)flag handler:(id < NSPersistentStoreCoordinatorSyncing >)syncHandler error:(NSError **)rError

Parameters
client

The client to sync.

flag

YES if syncing is non-blocking and occurs in a separate thread. NO if syncing blocks and occurs in the senders thread—in which case, this method returns when syncing finishes or cancels.

syncHandler

Application supplied object that can optionally intervene during the sync session.

outError

If the receiver fails to sync, an NSError object describing the error.

Return Value

NO If the receiver is unable to create a sync session or an error occurs during the sync; otherwise, YES.

Discussion

Pass YES for the inBackground: parameter if you do not want this method to block—for example, if you are handling a sync alert and you registered the sync alert handler on the main thread.

Availability
Declared In
ISyncCoreData.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-07-11)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.