RefCounted

    Base class for reference-counted objects.

    RefCounted.swift:20
    class RefCounted

    Base class for any object that keeps a reference count. Resource and many other helper objects inherit this class.

    Unlike other Object types, RefCounteds keep an internal reference counter so that they are automatically released when no longer in use, and only then. RefCounteds therefore do not need to be freed manually with Object/free().

    RefCounted instances caught in a cyclic reference will not be freed automatically. For example, if a node holds a reference to instance A, which directly or indirectly holds a reference back to A, A’s reference count will be 2. Destruction of the node will leave A dangling with a reference count of 1, and there will be a memory leak. To prevent this, one of the references in the cycle can be made weak with @GlobalScope.weakref.

    In the vast majority of use cases, instantiating and using RefCounted-derived types is all you need to do. The methods provided in this class are only for advanced users, and can cause issues if misused.

    Superclasses

    Citizens in SwiftGodot

    Conformances

    • protocol CustomStringConvertible

      A type with a customized textual representation.

    • protocol Equatable

      A type that can be compared for value equality.

    • protocol Hashable

      A type that can be hashed into a Hasher to produce an integer hash value.

    • protocol Identifiable<ID>

      A class of types whose instances hold the value of an entity with stable identity.

    • protocol VariantRepresentable

      Types that conform to VariantRepresentable can be stored directly in Variant with no conversion. These include all of the Variant types from Godot (for example GString, Rect, Plane), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.

    • protocol VariantStorable

      Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.

    Type members

    Instance members

    Show implementation details (1)

    Hide implementation details

    • func _exp_unref()

      Decrements the internal reference counter. Deletes underlying object if it goes to zero..

    Subclasses