Q:

Comparing protocol references

I have an array of protocols.  now I want to remove an item from the array, by finding the index of the protocol with the array.  however, when comparing the protocol object with the items in the array, the compiler warns with:

'Protocol' does not conform to AnyObject

protocol SomeProtocol {}
var list:[SomeProtocol] = []
func add(some:SomeProtocol) { list+=some }
func remove(some:SomeProtocol) {
    var index = -1
    for i in 0...list.count-1 { if [i] === some { index = i } }
    if index >= 0 { list.removeAtIndex(index) }
}

A:

If you derive only classes for the protocol, you can change protocol definition to:
protocol SomeProtocol: class {}

Then you will be able to use references with this protocol.