Class CKSyncEngineState

  • All Implemented Interfaces:
    NSObject

    public class CKSyncEngineState
    extends NSObject
    An object that tracks some state required for proper and efficient operation of `CKSyncEngine`. `CKSyncEngine` needs to track several things in order to properly sync. For example, it needs to remember the last server change tokens for your database and zones. It also needs to keep track of things like the last known user record ID and other various pieces of state. A lot of this state is hidden internally, but some of it you can control. ## Pending changes One of the main things you can control is the list of pending changes to send to the server. You can control these by calling functions like ``addPendingDatabaseChanges:`` and ``addPendingRecordZoneChanges:``. When you add new pending changes, the sync engine will automatically schedule a task to sync with the server. ## State serialization `CKSyncEngine` will occasionally update its state in the background. When it updates its state, your delegate will receive a ``CKSyncEngineStateUpdateEvent``. This event will contain a ``CKSyncEngineStateSerialization``, which you should persist locally. The next time your process launches, you initialize your sync engine with the last state serialization you received. API-Since: 17.0
    • Constructor Detail

      • CKSyncEngineState

        protected CKSyncEngineState​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • addPendingDatabaseChanges

        public void addPendingDatabaseChanges​(@NotNull
                                              @NotNull NSArray<? extends CKSyncEnginePendingDatabaseChange> changes)
        Adds to the list of pending database changes. When you add a new pending change, the sync engine will automatically schedule a sync task. The sync engine will ensure consistency and deduplicate these changes under the hood.
      • addPendingRecordZoneChanges

        public void addPendingRecordZoneChanges​(@NotNull
                                                @NotNull NSArray<? extends CKSyncEnginePendingRecordZoneChange> changes)
        Adds to the list of pending record zone changes. When you add a new pending change, the sync engine will automatically schedule a sync task. The sync engine will ensure consistency and deduplicate these changes under the hood.
      • allocWithZone

        public static CKSyncEngineState allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull org.moe.natj.objc.Class classForKeyedUnarchiver()
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hasPendingUntrackedChanges

        public boolean hasPendingUntrackedChanges()
        This represents whether or not you have pending changes to send to the server that aren't tracked in `pendingRecordZoneChanges`. This is useful if you want to track pending changes in your own local database instead of the sync engine state. When this property is set, the sync engine will automatically schedule a sync. When the sync task runs, it will ask your delegate for pending changes in `nextRecordZoneChangeBatch`.
      • hash_static

        public static long hash_static()
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • pendingDatabaseChanges

        @NotNull
        public @NotNull NSArray<? extends CKSyncEnginePendingDatabaseChange> pendingDatabaseChanges()
        A list of database changes that need to be sent to the server, similar to `pendingRecordZoneChanges`.
      • pendingRecordZoneChanges

        @NotNull
        public @NotNull NSArray<? extends CKSyncEnginePendingRecordZoneChange> pendingRecordZoneChanges()
        A list of record changes that need to be sent to the server. `CKSyncEngine` provides the convenience of tracking your pending record zone changes. When the user makes some changes that need to be sent to the server, you can track them in this list. Then, you can use this list when creating your next `CKSyncEngineRecordZoneChangeBatch` in your `CKSyncEngineDelegate`. The sync engine will ensure consistency and deduplicate these pending changes under the hood. For example, if you add a pending save for record A, then record B, then record A again, this will result in a list of `[saveRecordA, saveRecordB]`. Similarly, if you add a pending save for record A, then add a pending delete for the same record A, this will result in a single pending change of `[deleteRecordA]`. The sync engine will manage this list while it sends changes to the server. For example, when it successfully saves a record, it will remove that change from this list. If it fails to send a change due to some retryable error (e.g. a network failure), it will keep that change in this list. If you'd prefer to track pending changes yourself, you can use `hasPendingUntrackedChanges` instead.
      • removePendingDatabaseChanges

        public void removePendingDatabaseChanges​(@NotNull
                                                 @NotNull NSArray<? extends CKSyncEnginePendingDatabaseChange> changes)
        Removes from the list of pending database changes.
      • removePendingRecordZoneChanges

        public void removePendingRecordZoneChanges​(@NotNull
                                                   @NotNull NSArray<? extends CKSyncEnginePendingRecordZoneChange> changes)
        Removes from the list of pending record zone changes.
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setHasPendingUntrackedChanges

        public void setHasPendingUntrackedChanges​(boolean value)
        This represents whether or not you have pending changes to send to the server that aren't tracked in `pendingRecordZoneChanges`. This is useful if you want to track pending changes in your own local database instead of the sync engine state. When this property is set, the sync engine will automatically schedule a sync. When the sync task runs, it will ask your delegate for pending changes in `nextRecordZoneChangeBatch`.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.
      • version_static

        public static long version_static()
      • zoneIDsWithUnfetchedServerChanges

        @NotNull
        public @NotNull NSArray<? extends CKRecordZoneID> zoneIDsWithUnfetchedServerChanges()
        The list of zone IDs that have new changes to fetch from the server. `CKSyncEngine` keeps track of these zones and will update this list as it receives new information.