Because your class inherits from NSObject
you do not need to use the swift protocol Equatable
instead you must override the NSObject
method isEquals
:
Swift 3.x and above
class FooBar: NSObject, NSCoding {
override func isEqual(_ object: Any?) -> Bool {
return id == (object as? FooBar)?.id
}
}
(Thanks to Kamchatka)
Swift 2.x
class FooBar: NSObject, NSCoding {
override func isEqual(object: AnyObject?) -> Bool {
return id == (object as? FooBar)?.id
}
}