ObjectPool

@objcMembers public final class ObjectPool: NSObject

Handles the management of recyclable objects.

  • If a recycled object is available for re-use, that object is returned.

    If not, a new object of the given type is instantiated.

    Note

    Objects obtained through this method should be recycled through recycleObject(:).

    Declaration

    Swift

    public func object<T>(forType type: T.Type) -> T where T: NSObject

    Return Value

    An object of the given type.

  • Calls prepareForReuse() on the object and stores it for re-use later.

    Note

    Objects recycled through this method should be obtained through objectForType(:) or recyclableObjectForType(:).

    Declaration

    Swift

    public func recycleObject(_ object: Recyclable)
  • Removes all recycled objects from memory.

    Declaration

    Swift

    public func removeAllRecycledObjects()