Getting ready

To explore each of these access levels, we need to step outside our playground comfort zone and create a module. To hold our module and a playground that can use it, we will need to create an Xcode workspace:

  1. In Xcode, select File | New | Workspace... from the menu, as shown in the following screenshot:
  1. Give your Workspace a name, such as AccessControl, and choose a save location.
  1. You will now see an empty workspace:

In this workspace, we need to create a module, which represents something that tightly controls the information it exposes and the information that it keeps hidden. So, we will make a module to represent Apple, the company.

  1. Create a new project from the Xcode menu by selecting File | New | Project..., as illustrated in the following screenshot:
  1. From the template selector, select Cocoa Touch Framework:
  1. Name the project AppleInc:
  1. Choose a location and at the bottom of the window, ensure that Add to: is set to be the workspace we just created:
  1. Now that we have a module, let's set up a playground to use it in. From the Xcode menu, select File | New | Playground..., as in the following screenshot:
  1. Give the playground a name and save location:
  1. This playground will not be added to the workspace automatically; you will need to locate the playground you just created and drag it into the file explorer pane on the left-hand side of your workspace.
  1. Press the run button on the Xcode toolbar to build the AppleInc module:
  1. Select the playground from the file navigator and add an import statement at the top of the file:
import AppleInc 

We are now ready to look into the different access controls that are available.