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

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -