Q:

Identity comparison of properties in swift

I am trying to filter out instances of an object in an array (remove an observer from a list of observers to be specific):
private var observers = [ChooserObserver]()

...

func unregisterObserver(observer: ChooserObserver ) {
    observers = observers.filter { includeElement in includeElement === observer }
}

...

protocol ChooserObserver {
    var path: String { get set }
}

Unfortunately, I get the following error:

Type 'ChooserObserver' does not conform to protocol 'AnyObject'

If I attempt to allow ChooserObserver to inherit AnyObject like so:
protocol ChooserObserver: AnyObject {
    var path: String { get set }
}

I am met with the following error:

Cannot declare explicit conformance to the 'AnyObject' protocol

When I attempt to cast to AnyObject:
func unregisterObserver(observer: ChooserObserver ) {
    observers = observers.filter { includeElement in includeElement as AnyObject !== observer as AnyObject }
}

I get these errors:

Partial application of struct method is not allowed
Cannot downcast from 'ChooserObserver' to non-@objc protocol type 'AnyObject'

I can only fix by appending @objc to my protocol in conjunction with the previous cast to AnyObject:
@objc protocol ChooserObserver {
    var path: String { get set }
}

Is this necessary, and if so why? I realize that an NSMutableSet would probably be appropriate here, but I am trying to understand Swift's type system.

A:

If I attempt to allow ChooserObserver to inherit AnyObject like so:
  I am met with the following error:

The correct syntax is
protocol ChooserObserver : class {
    //...
}

(Probably Apple should have just allowed you to do : AnyObject to avoid needing this new syntax.)

