Using as a concrete type conforming to protocol AnyObject is not supported

前端 未结 6 1324
时光取名叫无心
时光取名叫无心 2020-12-05 00:12

I\'m using Swift 2 and using WeakContainer as a way to store a set of weak objects, much like NSHashTable.weakObjectsHashTable()

struct WeakCont         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 00:52

    If your Protocol can be marked as @obj then you can use code below

    protocol Observerable {
    
        associatedtype P : AnyObject
    
        var delegates: NSHashTable

    { get } } @objc protocol MyProtocol { func someFunc() } class SomeClass : Observerable { var delegates = NSHashTable.weakObjects() }

提交回复
热议问题