Inherits from NSObject
Declared in PKSyncManager.h

Overview

The sync manager is responsible for listening to changes from a Core Data NSManagedObjectContext and a Dropbox DBDatastore and syncing the changes between them.

Properties

datastore

The Dropbox Datastore to read and write to.

@property (nonatomic, strong, readonly) DBDatastore *datastore

Declared In

PKSyncManager.h

managedObjectContext

The Core Data managed object context to listen for changes from.

@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext

Discussion

The managed object context must have a persistent store coordinator set.

Declared In

PKSyncManager.h

syncAttributeName

The Core Data entity attribute name to use for keeping managed objects in sync.

@property (nonatomic, copy) NSString *syncAttributeName

Discussion

The default value is “syncID”.

Declared In

PKSyncManager.h

syncBatchSize

The number of Core Data managed objects to sync with the DBDatastore at a time.

@property (nonatomic) NSUInteger syncBatchSize

Discussion

The DBDatastore has a 2 MiB delta size limit so changes in the managed object context must be batched to remain below this limit.

The default value is “20”. (2048 KiB max delta size / 100 KiB max record size)

Declared In

PKSyncManager.h

Class Methods

syncID

Returns a random string suitable for using as a sync identifer.

+ (NSString *)syncID

Return Value

A random string suitable for using as a sync identifer.

Declared In

PKSyncManager.h

Instance Methods

entityNameForTable:

Returns the entity name associated with a given tableID.

- (NSString *)entityNameForTable:(NSString *)tableID

Parameters

tableID

The tableID for which to return the corresponding entity name.

Return Value

The entity name associated with tableID, or nil if no entity name is associated with tableID.

Declared In

PKSyncManager.h

entityNames

Returns an array of currently mapped Core Data entity names.

- (NSArray *)entityNames

Return Value

An array of currently mapped Core Data entity names.

Declared In

PKSyncManager.h

initWithManagedObjectContext:datastore:

The designated initializer used to specify the Core Data managed object context and the Dropbox data store that should be synchronized.

- (id)initWithManagedObjectContext:(NSManagedObjectContext *)managedObjectContext datastore:(DBDatastore *)datastore

Parameters

managedObjectContext

The Core Data managed object context the sync manager should listen for changes from.

datastore

The Dropbox data store the sync manager should listen for changes from and write changes to.

Return Value

A newly initialized PKSyncManager object.

Discussion

The managed object context must have a persistent store coordinator set.

Declared In

PKSyncManager.h

isObserving

Returns whether or not the sync manager is currently observing changes.

- (BOOL)isObserving

Return Value

NO if the sync manager is not observing changes, YES if it is.

Discussion

The default value is NO.

Declared In

PKSyncManager.h

removeTableForEntityName:

Removes the Core Data <-> Dropbox mapping for the given entity name.

- (void)removeTableForEntityName:(NSString *)entityName

Parameters

entityName

The Core Data entity name that should no longer be mapped to Dropbox.

Declared In

PKSyncManager.h

setTable:forEntityName:

Maps a single Core Data entity name to the corresponding Dropbox data store table name.

- (void)setTable:(NSString *)tableID forEntityName:(NSString *)entityName

Parameters

tableID

The Dropbox data store tableID that the entity name should be mapped to.

entityName

The Core Data entity name that should map to the given tableID.

Discussion

Replaces any existing relationship for the given entity name that may have been previously set. Will raise an NSInternalInconsistencyException if the entity does not contain a valid sync attribute.

Declared In

PKSyncManager.h

setTablesForEntityNamesWithDictionary:

Map multiple Core Data entity names to their corresponding Dropbox data store table name. Replaces all other existing relationships that may have been previously set.

- (void)setTablesForEntityNamesWithDictionary:(NSDictionary *)keyedTables

Parameters

keyedTables

Dictionary of key/value pairs where the key is the Core Data entity name and the value is the corresponding Dropbox data store table name.

Declared In

PKSyncManager.h

startObserving

Starts observing changes to the Core Data managed object context and the Dropbox data store.

- (void)startObserving

Declared In

PKSyncManager.h

stopObserving

Stops observing changes from the Core Data managed object context and the Dropbox data store.

- (void)stopObserving

Declared In

PKSyncManager.h

tableForEntityName:

Returns the tableID associated with a given entity name.

- (NSString *)tableForEntityName:(NSString *)entityName

Parameters

entityName

The entity name for which to return the corresponding tableID.

Return Value

The tableID associated with entityName, or nil if no tableID is associated with entityName.

Declared In

PKSyncManager.h

tableIDs

Returns an array of currently mapped Dropbox data store tableIDs.

- (NSArray *)tableIDs

Return Value

An array of currently mapped Dropbox data store tableIDs.

Declared In

PKSyncManager.h

tablesByEntityName

Returns a dictionary of tables mapped to their corresponding entity names.

- (NSDictionary *)tablesByEntityName

Return Value

A dictionary of tables mapped to their corresponding entity names.

Declared In

PKSyncManager.h