I make a extension for Array where Elements are Object, so I can compare them by their address.
public extension Array where Element: AnyObject {
    func hasExactSameItem(_ searchingItem: Element) -> Bool {
        guard let _ = indexOfExactSameItem(searchingItem) else { return false }
        return true
    }
    func indexOfExactSameItem(_ searchingItem: Element) -> Int? {
        for (index, item) in self.enumerated() {
            if searchingItem === item {
                return index
            }
        }
        return nil
    }
}
There is another protocol conforming AnyObject protocol
public protocol IMServerListener: AnyObject {
    
}
I have a array containing IMServerListener
private var listeners = [IMServerListener]()
When I start adding listener to that array, the compiler complaining that '[IMServerListener]' requires that 'IMServerListener' conform to 'AnyObject'
func addListener(_ listener: IMServerListener) {
     listeners.hasExactSameItem(listener)
 }
I thought the IMServerListener is conforming the AnyObject protocol, so why did it happened?
 
    