ReceiptSpindle

open class ReceiptSpindle

Allows you to store related receipts together in a single place, to prevent proliferation of Receipt references that might defeat certain memory management strategies, such as relying on automatic de-registration upon Receipt deallocation.

  • Creates a new ReceiptSpindle using the specified LockMechanism.

    Declaration

    Swift

    public init(lock mechanism: LockMechanism = .readWrite)

    Parameters

    mechanism

    A LockMechanism value that governs the type of lock used for protecting concurrent access to the spindle.

  • Creates a new ReceiptSpindle using the specified Lock.

    Declaration

    Swift

    public init(lock: Lock)

    Parameters

    lock

    The Lock instance that will be used for protecting concurrent access to the spindle.

  • Adds a receipt to the spindle, ensuring that the receipt (and the object it references) is not deallocated.

    Declaration

    Swift

    open func add(_ receipt: Receipt)
            -> ObjectIdentifier

    Parameters

    receipt

    The Receipt to add to the spindle.

    Return Value

    A receipt identifier that can be used to remove receipt from the spindle at a later time.

  • Removes the Receipts with the given identifiers from the spindle.

    Declaration

    Swift

    open func remove(_ receiptIDs: [ObjectIdentifier])
            -> Int

    Parameters

    receiptIDs

    The ObjectIdentifiers of the Receipts to be removed from the spindle.

    Return Value

    The number of receipts removed from the spindle.

  • Removes the Receipt with the given identifier from the spindle.

    Declaration

    Swift

    open func remove(_ receiptID: ObjectIdentifier)
            -> Bool

    Parameters

    receiptID

    The ObjectIdentifier of the Receipt to be removed from the spindle.

    Return Value

    true if there was a Receipt on the spindle for the receiptIdentifier (and it was removed); false if nothing was done because no receipt with the given identifier was found on the spindle.