UserInfo

public final class UserInfo

The UserInfo class is provided by several CoreStore types such as DataStack, ListMonitor, ObjectMonitor and transactions to allow external libraries or user apps to store their own custom data.

enum Static {
    static var myDataKey: Void?
}
CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey] = myObject

Important

Do not use this class to store thread-sensitive data.
  • Allows external libraries to store custom data. App code should rarely have a need for this.

    enum Static {
       static var myDataKey: Void?
    }
    CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey] = myObject
    

    Important

    Do not use this method to store thread-sensitive data.

    Declaration

    Swift

    public subscript(key: UnsafeRawPointer) -> Any? { get set }

    Parameters

    key

    the key for custom data. Make sure this is a static pointer that will never be changed.

  • Allows external libraries to store custom data in the DataStack. App code should rarely have a need for this.

    enum Static {
        static var myDataKey: Void?
    }
    CoreStoreDefaults.dataStack.userInfo[&Static.myDataKey, lazyInit: { MyObject() }] = myObject
    

    Important

    Do not use this method to store thread-sensitive data.

    Declaration

    Swift

    public subscript(key: UnsafeRawPointer, lazyInit closure: () -> Any) -> Any { get }

    Parameters

    key

    the key for custom data. Make sure this is a static pointer that will never be changed.

    lazyInit

    a closure to use to lazily-initialize the data

    Return Value

    A custom data identified by key