O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Challenge: Make Course Implement Equatable

You have implemented several tests (testCourseInitialization(), testCreateCourseFromValidDictionary(), testResultFromValidHTTPResponseAndValidData(_:), testFetcherSuccess()) that compare the properties of Course objects to determine that they are equal. Make Course adopt the Equatable protocol allowing instances of Course to be compared. Take advantage of this by using XCTAssertEqual in your tests.

To make Course adopt Equatable you will need to implement a free function with this signature:

 ​ ​ ​ ​p​u​b​l​i​c​ ​f​u​n​c​ ​=​=​(​l​h​s​:​ ​C​o​u​r​s​e​,​ ​r​h​s​:​ ​C​o​u​r​s​e​)​ ​-​>​ ​B​o​o​l​

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required