A blog about Swift and iOS tricks

Comparing Reference types

Equitable doesn't fit as well with reference types as with value types. Here is a nice Equitable extension to deal with reference types.

extension Equatable where Self: AnyObject {
    static func ==(lhs: Self, rhs: Self) -> Bool {
        return lhs === rhs

// Usage
class View: Equatable { }
let view = View()
let views = [View]()