SFSyncUpTarget Class Reference

Inherits from SFSyncTarget : NSObject
Declared in SFSyncUpTarget.h

Overview

Base class for a server target, used to manage sync ups to the configured service.

Other Methods

  targetType

The type of server target represented by this instance.

@property (nonatomic, assign) SFSyncUpTargetType targetType

Declared In

SFSyncUpTarget.h

  createFieldlist

Create field list (optional)

@property (nonatomic, strong, readonly) NSArray<NSString*> *createFieldlist

Declared In

SFSyncUpTarget.h

  updateFieldlist

Update field list (optional)

@property (nonatomic, strong, readonly) NSArray<NSString*> *updateFieldlist

Declared In

SFSyncUpTarget.h

  externalIdFieldName

External id field name (optional)

@property (nonatomic, copy) NSString *externalIdFieldName

Declared In

SFSyncUpTarget.h

+ newFromDict:

Creates a new instance of a server target from a serialized dictionary.

+ (nullable instancetype)newFromDict:(nullable NSDictionary *)dict

Parameters

dict

The dictionary with the serialized server target.

Declared In

SFSyncUpTarget.h

+ targetTypeFromString:

Converts a string representation of a target type into its target type.

+ (SFSyncUpTargetType)targetTypeFromString:(NSString *)targetType

Parameters

targetType

The string representation of the target type.

Return Value

The target type value.

Declared In

SFSyncUpTarget.h

+ targetTypeToString:

Gives the string representation of a target type.

+ (NSString *)targetTypeToString:(SFSyncUpTargetType)targetType

Parameters

targetType

The target type to display.

Return Value

The string representation of the target type.

Declared In

SFSyncUpTarget.h

– initWithCreateFieldlist:updateFieldlist:

Constructor

- (instancetype)initWithCreateFieldlist:(nullable NSArray<NSString*> *)createFieldlist updateFieldlist:(nullable NSArray<NSString*> *)updateFieldlist

Declared In

SFSyncUpTarget.h

– isNewerThanServer:record:resultBlock:

Call resultBlock with YES if record is more recent than corresponding record on server NB: also call resultBlock true if both were deleted or if local mod date is missing Used to decide whether a record should be synced up or not when using merge mode leave-if-changed

- (void)isNewerThanServer:(SFMobileSyncSyncManager *)syncManager record:(NSDictionary *)record resultBlock:(SFSyncUpRecordNewerThanServerBlock)resultBlock

Parameters

record

The record

resultBlock

The block to execute

Declared In

SFSyncUpTarget.h

– isNewerThanServer:remoteModDate:

Return true if local mod date is greater than remote mod date NB: also return true if both were deleted or if local mod date is missing

- (BOOL)isNewerThanServer:(nullable SFRecordModDate *)localModDate remoteModDate:(nullable SFRecordModDate *)remoteModDate

Declared In

SFSyncUpTarget.h

– areNewerThanServer:records:resultBlock:

Same as isNewerThanServer but operating over a list of records Return dictionary from record store id to boolean

- (void)areNewerThanServer:(SFMobileSyncSyncManager *)syncManager records:(NSArray<NSDictionary*> *)records resultBlock:(SFSyncUpRecordsNewerThanServerBlock)resultBlock

Parameters

records

The records

resultBlock

The block to execute

Declared In

SFSyncUpTarget.h

– createOnServer:record:fieldlist:completionBlock:failBlock:

Save locally created record back to server

- (void)createOnServer:(SFMobileSyncSyncManager *)syncManager record:(NSDictionary *)record fieldlist:(NSArray *)fieldlist completionBlock:(SFSyncUpTargetCompleteBlock)completionBlock failBlock:(SFSyncUpTargetErrorBlock)failBlock

Parameters

syncManager

The sync manager doing the sync

record

The record being synced

fieldlist

List of fields to send to server

completionBlock

The block to execute after the server call completes.

failBlock

The block to execute if the server call fails.

Declared In

SFSyncUpTarget.h

– updateOnServer:record:fieldlist:completionBlock:failBlock:

Save locally updated record back to server

- (void)updateOnServer:(SFMobileSyncSyncManager *)syncManager record:(NSDictionary *)record fieldlist:(NSArray *)fieldlist completionBlock:(SFSyncUpTargetCompleteBlock)completionBlock failBlock:(SFSyncUpTargetErrorBlock)failBlock

Parameters

syncManager

The sync manager doing the sync

record

The record being synced

fieldlist

List of fields to send to server

completionBlock

The block to execute after the server call completes.

failBlock

The block to execute if the server call fails.

Declared In

SFSyncUpTarget.h

– deleteOnServer:record:completionBlock:failBlock:

Delete locally deleted record from server

- (void)deleteOnServer:(SFMobileSyncSyncManager *)syncManager record:(NSDictionary *)record completionBlock:(SFSyncUpTargetCompleteBlock)completionBlock failBlock:(SFSyncUpTargetErrorBlock)failBlock

Parameters

syncManager

The sync manager doing the sync

record

The record being synced

completionBlock

The block to execute after the server call completes.

failBlock

The block to execute if the server call fails.

Declared In

SFSyncUpTarget.h

– getIdsOfRecordsToSyncUp:soupName:

Return set of record ids (soup element ids) that need to be sent up to the server

- (NSArray *)getIdsOfRecordsToSyncUp:(SFMobileSyncSyncManager *)syncManager soupName:(NSString *)soupName

Parameters

syncManager

The sync manager running the sync.

soupName

The soup name to look into for records.

Declared In

SFSyncUpTarget.h

– saveRecordToLocalStoreWithLastError:soupName:record:

Save record with last error if any

- (void)saveRecordToLocalStoreWithLastError:(SFMobileSyncSyncManager *)syncManager soupName:(NSString *)soupName record:(NSDictionary *)record

Parameters

syncManager

The sync manager doing the sync

soupName

the soup to save the record to

record

The record being synced

Declared In

SFSyncUpTarget.h

Extension Methods

– buildFieldsMap:fieldlist:idFieldName:modificationDateFieldName:

- (NSMutableDictionary *)buildFieldsMap:(NSDictionary *)record fieldlist:(NSArray *)fieldlist idFieldName:(NSString *)idFieldName modificationDateFieldName:(NSString *)modificationDateFieldName

– saveRecordToLocalStoreWithLastError:soupName:record:lastError:

- (void)saveRecordToLocalStoreWithLastError:(SFMobileSyncSyncManager *)syncManager soupName:(NSString *)soupName record:(NSDictionary *)record lastError:(NSString *)lastError