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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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