PlaygroundPage
An object you use to configure the state of a playground page and its live view.
Declaration
final class PlaygroundPageOverview
You access the current playground page by using this class's static current property; no more than one page is ever active at the same time. Playground pages in Swift Playgrounds have different capabilities than playground pages in Xcode. For example, control over the execution mode is available only in Swift Playgrounds, while the Touch Bar is accessible only to playgrounds in Xcode.
Both playground environments can set a live view, which you use to show the visual results of running the code on the playground page.
PlaygroundPage.current.setLiveView(
List(0..<42) { number in
Text("My favorite number is \(number).")
}
)You also use the current page to configure the always-on live view, a special live view that runs in a separate process from the code on a playground page and is available only in Swift Playgrounds. The always-on live view can display results that persist across multiple runs of the code on a page, or that you need for one-time setup tasks that take time to run. For example, you might use the always-on live view to display multiple stages of progress through a playground page that has multiple steps to reach the solution.
Because the always-on live view is hosted outside of the process that runs the code on a playground page, you communicate with it indirectly. For more information, see Messaging Between a Playground Page and the Always-On Live View.
Topics
Configuring Live Views
Configuring Execution
Assessing Progress
Inspecting Page Data
Displaying Touch Bar Items
Instance Properties
Instance Methods
getText(forSourceFile:inUserModule:)listSourceFiles(inUserModule:)navigateTo(page:)openApplication(withBundleIdentifier:iTunesItemIdentifier:)openPlayground(withContentIdentifier:toPageAtIndex:)showGlossaryEntry(named:at:in:)