How it works...

Let's examine our SecretProductDepartment class to see how the visibility matches our model:

internal class SecretProductDepartment {          private var secretCodeWord = "Titan"     private var secretProducts = ["iPhone 8",                                   "Apple Car",                                   "Apple Brain Implant",                                   "Apple Spaceship"]          func nextProduct(givenCodeWord codeWord: String) -> String? {         let codeCorrect = codeWord == secretCodeWord         return codeCorrect ? secretProducts.first : nil     } } 

The SecretProductDepartment class is declared without an access control keyword, and when no access control is specified, the default control of internal is applied. Since we want the secret product department to be visible within Apple, but not from outside Apple, this is the correct access ...

Get Swift 4 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.