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 specifiedLockMechanism
.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. -
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
Receipt
s with the given identifiers from the spindle.Declaration
Swift
open func remove(_ receiptIDs: [ObjectIdentifier]) -> Int
Parameters
receiptIDs
The
ObjectIdentifier
s of theReceipt
s 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 theReceipt
to be removed from the spindle.Return Value
true
if there was aReceipt
on the spindle for thereceiptIdentifier
(and it was removed);false
if nothing was done because no receipt with the given identifier was found on the spindle.