Errata: Equatable challenge gives wrong advice for Swift 2.0


The challenge mentions that one should implement a global function == but with Swift 2.0 this is wrong.

In Swift 2.0 subclasses of NSObject are never compared using the == function but rather using their isEqual method.

So to correctly implement equality (spoiler alert) add this to your Course class:

override func isEqual(object: AnyObject?) -> Bool { if let rhs = object as? Course { return title == rhs.title && url == rhs.url && nextStartDate == rhs.nextStartDate } return false }


This helped, even using Swift 4.2, thanks!