swift - Force a generic type parameter to be a class type? -
i'm trying figure out method avoiding retain cycles when references in cycle held in collections. idea create wrapper struct:
struct weak<t> { unowned let value: t init(_ value: t) { self.value = value } } the issue here unowned , weak members have of class type (main.swift:3:17: 'unowned' cannot applied non-class type 't'; consider adding class bound), there's no reasonable superclass me require t inherit from.
is there way force t of class type without inheriting specific other class?
try:
struct weak<t:anyobject>
Comments
Post a Comment