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

Sharing Constants

All of the constants that you have used so far you have put into Constants.swift. It would have been technically possible to add each of these constants to the top of the test file that you used them in. However, as you have already seen, it is quite common to use the same constants in multiple tests and in multiple test files. On the one hand, if you do not put constants in the files where they are first used, they will be visible from other test files – so long as you do not mark them private. On the other hand, if you follow this approach, your shared constants will be scattered throughout your test files and harder to track down.

For this reason, stylish Swift programmers put their shared test constants into a ...

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