PKSyncManager Class Reference
| 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.
Tasks
Other Methods
-
managedObjectContextproperty -
datastoreproperty -
syncAttributeNameproperty -
syncBatchSizeproperty -
+ syncID
Creating and Configuring a Sync Manager
-
– initWithManagedObjectContext:datastore: -
– setTablesForEntityNamesWithDictionary: -
– setTable:forEntityName: -
– removeTableForEntityName:
Accessing Entity Names and Tables
Observing Changes
Properties
datastore
The Dropbox Datastore to read and write to.
@property (nonatomic, strong, readonly) DBDatastore *datastoreDeclared In
PKSyncManager.hmanagedObjectContext
The Core Data managed object context to listen for changes from.
@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContextDiscussion
The managed object context must have a persistent store coordinator set.
Declared In
PKSyncManager.hsyncAttributeName
The Core Data entity attribute name to use for keeping managed objects in sync.
@property (nonatomic, copy) NSString *syncAttributeNameDiscussion
The default value is “syncID”.
Declared In
PKSyncManager.hsyncBatchSize
The number of Core Data managed objects to sync with the DBDatastore at a time.
@property (nonatomic) NSUInteger syncBatchSizeDiscussion
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.hInstance Methods
entityNameForTable:
Returns the entity name associated with a given tableID.
- (NSString *)entityNameForTable:(NSString *)tableIDParameters
- 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.hentityNames
Returns an array of currently mapped Core Data entity names.
- (NSArray *)entityNamesReturn Value
An array of currently mapped Core Data entity names.
Declared In
PKSyncManager.hinitWithManagedObjectContext: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 *)datastoreParameters
- 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.hisObserving
Returns whether or not the sync manager is currently observing changes.
- (BOOL)isObservingReturn Value
NO if the sync manager is not observing changes, YES if it is.
Discussion
The default value is NO.
Declared In
PKSyncManager.hremoveTableForEntityName:
Removes the Core Data <-> Dropbox mapping for the given entity name.
- (void)removeTableForEntityName:(NSString *)entityNameParameters
- entityName
The Core Data entity name that should no longer be mapped to Dropbox.
Declared In
PKSyncManager.hsetTable:forEntityName:
Maps a single Core Data entity name to the corresponding Dropbox data store table name.
- (void)setTable:(NSString *)tableID forEntityName:(NSString *)entityNameParameters
- 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.hsetTablesForEntityNamesWithDictionary:
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 *)keyedTablesParameters
- 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.hstartObserving
Starts observing changes to the Core Data managed object context and the Dropbox data store.
- (void)startObservingDeclared In
PKSyncManager.hstopObserving
Stops observing changes from the Core Data managed object context and the Dropbox data store.
- (void)stopObservingDeclared In
PKSyncManager.htableForEntityName:
Returns the tableID associated with a given entity name.
- (NSString *)tableForEntityName:(NSString *)entityNameParameters
- 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