AWSCognitoDataset
Objective-C
@interface AWSCognitoDataset : AWSCognitoDatasetMetadata
Swift
class AWSCognitoDataset : AWSCognitoDatasetMetadata
An object that encapsulates the dataset. The dataset is the unit of sync for Amazon Cognito.
-
A conflict resolution handler that will receive calls when there is a conflict during a sync operation. A conflict will occur when both remote and local data have been updated since the last sync time. When not explicitly set, we will use the default conflict resolution of ‘last writer wins’, where the data most recently updated will be persisted.
Declaration
Objective-C
@property (nonatomic, copy) AWSCognitoRecordConflictHandler conflictHandler;
Swift
var conflictHandler: AWSCognitoRecordConflictHandler! { get set }
-
A deleted dataset handler. This handler will be called during a synchronization when the remote service indicates that a dataset has been deleted. Returning YES from the handler will cause the service to recreate the dataset on the remote on the next synchronization. Returning NO or leaving this property nil will cause the client to delete the dataset locally.
Declaration
Objective-C
@property (nonatomic, copy) AWSCognitoDatasetDeletedHandler datasetDeletedHandler;
Swift
var datasetDeletedHandler: AWSCognitoDatasetDeletedHandler! { get set }
-
A merged dataset handler. This handler will be called during a synchronization when the remote service indicates that other datasets should be merged with this one. Merged datasets should be fetched, their data overlayed locally and then removed. Failing to implement this handler will result in merged datasets remaining on the service indefinitely.
Declaration
Objective-C
@property (nonatomic, copy) AWSCognitoDatasetMergedHandler datasetMergedHandler;
Swift
var datasetMergedHandler: AWSCognitoDatasetMergedHandler! { get set }
-
The number of times to attempt a synchronization before failing. Defaults to to the value on the AWSCognito client that opened this dataset.
Declaration
Objective-C
@property (nonatomic) uint32_t synchronizeRetries;
Swift
var synchronizeRetries: UInt32 { get set }
-
Only synchronize if device is on a WiFi network. Defaults to to the value on the AWSCognito client that opened this dataset.
Declaration
Objective-C
@property (nonatomic) BOOL synchronizeOnWiFiOnly;
Swift
var synchronizeOnWiFiOnly: Bool { get set }
-
Sets a string object for the specified key in the dataset.
Declaration
Objective-C
- (void)setString:(NSString *)aString forKey:(NSString *)aKey;
Swift
func setString(_ aString: String!, forKey aKey: String!)
-
Returns the string associated with the specified key.
Declaration
Objective-C
- (NSString *)stringForKey:(NSString *)aKey;
Swift
func string(forKey aKey: String!) -> String!
-
Synchronize local changes with remote changes on the service. First it pulls down changes from the service and attempts to overlay them on the local store. Then it pushes any local updates to the service. If at any point there is a conflict, conflict resolution is invoked. No changes are pushed to the service until all conflicts are resolved.
Declaration
Objective-C
- (AWSTask *)synchronize;
Swift
func synchronize() -> AWSTask!
-
Attempts to synchronize when device has connectivity. First it checks connectivity, if device is online immediately invokes synchronize and returns the AWSTask associated with the attempt. If the device is offline, schedules a synchronize for the next time the device comes online and returns a AWSTask with a nil result. The scheduled synchronize is only valid for the lifecycle of the dataset object. The data will not be synchronized if the app is exited before connectivity is regained. If you want to be notified when events occur during the scheduled synchronize, you must add observers of the notifications found in AWSCognito
Declaration
Objective-C
- (AWSTask *)synchronizeOnConnectivity;
Swift
func synchronizeOnConnectivity() -> AWSTask!
-
Subscribes this dataset to push notifications
Declaration
Objective-C
- (AWSTask *)subscribe;
Swift
func subscribe() -> AWSTask!
Return Value
AWSTask with nil result. task.error will contain any errors.
-
Unsubscribes this dataset to push notifications
Declaration
Objective-C
- (AWSTask *)unsubscribe;
Swift
func unsubscribe() -> AWSTask!
Return Value
AWSTask with nil result. task.error will contain any errors.
-
Returns all of the records in the dataset. Will return deleted records.
Declaration
Objective-C
- (NSArray<AWSCognitoRecord *> *)getAllRecords;
Swift
func getAllRecords() -> [AWSCognitoRecord]!
Return Value
NSArray of AWSCognitoRecord objects
-
Returns all the key value pairs in the dataset, ignore any deleted data.
Declaration
Objective-C
- (NSDictionary<NSString *, NSString *> *)getAll;
Swift
func getAll() -> [String : String]!
Return Value
NSDictionary of all key value pairs. Contains no metadata.
-
Remove a record from the dataset.
Declaration
Objective-C
- (void)removeObjectForKey:(NSString *)aKey;
Swift
func removeObject(forKey aKey: String!)
Parameters
aKey
the key to remove
-
Returns the record associated with the specified key.
Declaration
Objective-C
- (AWSCognitoRecord *)recordForKey:(NSString *)aKey;
Swift
func record(forKey aKey: String!) -> AWSCognitoRecord!
Parameters
aKey
the key to return
Return Value
AWSCognitoRecord for this particular record. Will return nil if record does not exist.
-
Clear this dataset locally. Dataset will not be removed from the service until the next synchronize call.
Declaration
Objective-C
- (void)clear;
Swift
func clear()
-
Returns the size in bytes for this dataset.
Declaration
Objective-C
- (long)size;
Swift
func size() -> Int
-
Returns the size in bytes for the specified key.
Declaration
Objective-C
- (long)sizeForKey:(NSString *)aKey;
Swift
func size(forKey aKey: String!) -> Int
Parameters
aKey
the key to check