ClientResetMode

public enum ClientResetMode

An enum used to determines file recovery behavior in the event of a client reset.

See

RLMClientResetMode
  • See

    RLMClientResetModeManual

    Declaration

    Swift

    case manual
  • See

    RLMClientResetModeDiscardLocal for more details on .discardLocal behavior

    The first .discardLocal function argument notifies prior to a client reset occurring. The Realm argument contains a frozen copy of the Realm state prior to client reset.

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardLocal({ beforeRealm in
       var recoveryConfig = Realm.Configuration()
       recoveryConfig.fileURL = myRecoveryPath
       do {
           beforeRealm.writeCopy(configuration: recoveryConfig)
           // The copied realm could be used later for recovery, debugging, reporting, etc.
       } catch {
           // handle error
       }
    }, nil))
    

    For more details on ((Realm) -> Void)? = nil,

    See

    RLMClientResetBeforeBlock

    The second .discardLocal function argument notifies after a client reset has occurred.

    • Within this function, the first Realm argument contains a frozen copy of the local Realm state prior to client reset.
    • Within this function, the second Realm argument contains the Realm state after client reset. user.configuration(partitionValue: "myPartition", clientResetMode: .discardLocal( nil, { beforeRealm, afterRealm in // This block could be used to add custom recovery logic, back-up a realm file, send reporting, etc. for object in before.objects(myClass.self) { let res = after.objects(myClass.self) if (res.filter("primaryKey == %@", object.primaryKey).first != nil) { // ...custom recovery logic... } else { // ...custom recovery logic... } } })) For more details on the second block: ((Realm, Realm) -> Void)? = nil,

    See

    RLMClientResetAfterBlock

    Declaration

    Swift

    case discardLocal(_: ((Realm) -> Void)? = nil, _: ((Realm, Realm) -> Void)? = nil)