Guides and Sample Code

Developer

Playground Book Format Reference

On This Page

Playground Page Manifest

The Manifest.plist file for a playground page contains the following key-value pairs specifying the attributes for a page:

  • User-viewable name for the page

  • Live view configuration

  • Playground logging configuration

  • Instructions for copying content between pages

The file is located at the top level of the .playgroundpage folder for the page.

Key List

Table 5-1 describes each key for a playground page, its type, and whether the key is required.

Table 5-1Keys for a playground page

Key

Type

Description

Required

CodeCopySetup

Dictionary

Configuration for copying code between playground pages. See CodeCopySetup Key.

 

LiveViewEdgeToEdge

Boolean

Sets the live view to extend past the margin in the area used for live views. See LiveViewEdgeToEdge Key.

LiveViewMode

String

Sets the live view to show even when it is not running. See LiveViewMode Key.

Name

String

The name displayed in the user interface. See Name Key.

PlaygroundLoggingMode

String

Controls the display of results in playground pages. See PlaygroundLoggingMode Key.

 

PosterReference

String

An image shown before the live view runs. See PosterReference Key.

 

CodeCopySetup Key

A dictionary of key-value pairs that specifies instructions shown to a user when copying content between playground pages.

Table 5-2 describes each key for the CodeCopySetup dictionary, its type, and whether the key is required.

Table 5-2Keys for a CodeCopySetup dictionary

Key

Type

Description

Required

CopyCommandButtonTitle

String

The title of the button used to copy the code to the current playground page. See CopyCommandButtonTitle Key.

DefaultCommandButtonTitle

String

The title of the button used to copy the default code to the current playground page. See DefaultCommandButtonTitle Key.

NavigateCommandButtonTitle

String

The title of the button used to navigate back to the playground page from which the code is copied. See NavigateCommandButtonTitle Key.

NotReadyToCopyInstructions

String

The instructions displayed when code isn’t ready to be copied to the current playground page, such as when a previous page has not been completed. See NotReadyToCopyInstructions Key.

ReadyToCopyInstructions

String

The instructions displayed when code is ready to be copied to the current playground page. See ReadyToCopyInstructions Key.

CopyCommandButtonTitle Key

The title for the copy command button.

If no value is specified, this defaults to “Copy my code”.

DefaultCommandButtonTitle Key

The title for the default command button.

If no value is specified, this defaults to “Start with provided code”.

NavigateCommandButtonTitle Key

The title for the navigate command button.

If no value is specified, this defaults to “Go to <PREVIOUS_PAGE>”, where <PREVIOUS_PAGE> is substituted for the name of the previous page.

NotReadyToCopyInstructions Key

The text to show when the code isn’t ready to be copied to the current page.

ReadyToCopyInstructions Key

The text to show when the code is ready to be copied to the current page.

LiveViewEdgeToEdge Key

A Boolean controlling the initial size of the live view. Setting the key to true expands the live view to fill the live view area, which includes the Run button and the Hints button. These buttons overlay the live view.

Figure 5-1 shows how the value of LiveViewEdgeToEdge changes the size of the live view. The playground page on the left side of the figure uses a value of NOfalse. The page on the right side of the figure uses a value of YEStrue.

Figure 5-1Effect of the LiveViewEdgeToEdge key value image: ../Art/SP_manifest_page_LVEdgeToEdge_compare_2x.png

LiveViewMode Key

Used to control the display of the live view area while the live view is not running.

The possible values for LiveViewMode are:

  • VisibleByDefault. Shows the live view when the playground opens.

  • HiddenByDefault. Hides the live view until the playground is run.

Figure 5-2 shows how the value of LiveViewMode affects the initial display of a live view area. The playground page on the left side of the figure uses a value of VisibleByDefault. The page on the right side of the figure uses a value of HiddenByDefault.

Figure 5-2Effect of the live view mode key value image: ../Art/SP_manifest_page_LVMode_compare_2x.png

Name Key

The display name of the playground page in the user interface; for example, the name of a page in the table of contents.

The name is also used as part of the link to the first use of a glossary term. (See PageReference Key in Glossary Property List.)

In Figure 5-3, Example Page is the name of the playground page in the table of contents.

Figure 5-3Playground page in the table of contents image: ../Art/SP_manifest_page_Name_TOC_2x.png

PlaygroundLoggingMode Key

Controls the display of results for executed playground statements.

The possible values for PlaygroundLoggingMode are:

  • Off. Playground logging is off and no results are displayed.

  • Normal. (Default value) Playground logging is on and results are displayed.

Figure 5-4 shows a playground with results for each of the executed statements. The user can tap the result to view the value, and then can add an inline result viewer. Turning off logging can speed up execution of playgrounds.

Figure 5-4Playground results image: ../Art/SP_manifest_page_PGLogMode_screen_2x.png

PosterReference Key

The base name of an image file that is shown centered and unscaled in the live view area before the live view runs. The image file can be in any Resources folder in the book. The book package can contain multiple resolutions of the same image. For more information on multiple resolutions, see Loading Image Resources in Resource Programming Guide.

Use PosterReference Key to show a small image such as a logo, or a large image that works for multiple screen sizes because the live view area can be resized.

In Figure 5-5, Llama logo.png is used to show a Llama in the center of the live view area of the playground page.

Figure 5-5Live view poster image image: ../Art/SP_manifest_page_PosterRef_screen_2x.png