Lets assume i have a protocol to what only classes can confirm, using that i create typealias
combined with some class type.
protocol Foo: class {}
typealias FooView = UIView & Foo
I would like to store instances of UIView
conforming to this protocol in a weak hash table. So i do:
let hashtable = NSHashTable<FooView>.weakObjects()
But i receive the following error:
'NSHashTable' requires that 'FooView' (aka 'Foo & UIView') be a class type
I understand that NSHashTable
only works with reference types, but what i do not get, since UIView
is reference type and Foo
protocol is also class type, IMHO it should be a valid declaration.
I understand, that i could just create a class like the following:
class FooView: UIView, Foo {}
And than it would probably work, however, that is not a possible solution. Does someone else have an other idea how to use typealias
and still store it in a HashTable
?