408 Introducing Swift Playgrounds 03 FINAL D

408 Introducing Swift Playgrounds 03 FINAL D

Developer Tools #WWDC16 Introducing Swift Playgrounds Exploring with Swift on iPad Session 408 Matt Patenaude Playgrounds Engineer Maxwell Swadling Playgrounds Engineer Jonathan Penn Playgrounds Engineer Izzy Fraimow Playgrounds Engineer © 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. 1024 x 768 1024 x 768 Using Swift Playgrounds Using Swift Playgrounds Authoring for Swift Playgrounds Using Swift Playgrounds Authoring for Swift Playgrounds Growing and Exploring Using Swift Playgrounds Maxwell Swadling Playgrounds Engineer Playground Markup Source Code Code Completion Undo/Redo Shortcuts Live View Run Button Documents Table of Contents Page Navigation Library Tools Menu Snippets Images Files Demo Using Swift Playgrounds Authoring for Swift Playgrounds Jonathan Penn Playgrounds Engineer Chapters / Pages Chapter: Commands Introduction Issuing Commands … Chapter: Functions Introduction Composing a New Behavior … Chapters / Pages Chapter: Commands Introduction Issuing Commands … Chapter: Functions Introduction Composing a New Behavior … Cutscenes Cutscenes Glossary Glossary Glossary Editable Regions Editable Regions func /*#-editable-code*/ <#funcName#> /*#-end-editable-code*/() { //#-editable-code Add commands to your function //#-end-editable-code } //#-editable-code Tap to enter code //#-end-editable-code Hidden Code Hidden Code //#-hidden-code yourSetupFunction() //#-end-hidden-code Configurable Code Completion Configurable Code Completion //#-code-completion(everything, hide) //#-code-completion(currentmodule, show) //#-code-completion(identifier, show, moveForward(), turnLeft()) “Always-On” Live View “Always-On” Live View Hints Hints Assessment Assessment Assessment Assessment // Key/Value Store import PlaygroundSupport let store = PlaygroundPage.current.keyValueStore store["Greeting"] = .string("Hello, WWDC!") if case let .string(greeting)? = store["Greeting"] { print(greeting) // "Hello, WWDC!" } Resettable Resettable Resettable Resettable Resettable Resettable Documented apple.com 1024 x 768 Demo Authoring for Swift Playgrounds MyFirst.playgroundbook Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Page Manifest Key Type Value Root Dictionary Name String Introduction LiveViewMode String VisibleByDefault PosterReference String LiveViewPoster.png LiveViewEdgeToEdge Boolean YES PlaygroundLoggingMode String Off Name = “Introduction” LiveViewMode = “VisibleByDefault” PosterReference = “LiveViewPoster.png” LiveViewEdgeToEdge = YES LiveViewEdgeToEdge = NO PlaygroundLoggingMode = “Off” Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … Contents.swift // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) // Contents.swift /*: Instructions about the page... */ //#-hidden-code import PlaygroundSupport func say(_ message: String) { let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { proxy.send(.string(message)) } } //#-end-hidden-code say(/*#-editable-code*/"<#Knock, knock!#>"/*#-end-editable-code*/) Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … // LiveView.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() // LiveView.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() // LiveView.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() // LiveView.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() Contents Sources Resources Chapters Chapter1.playgroundchapter Pages Introduction.playgroundpage Manifest.plist Contents.swift LiveView.swift HowDoesItWork.playgroundpage … import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() Contents.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() Contents.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() In main process Contents.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() In main process Only active while running Contents.swift import PlaygroundSupport let page = PlaygroundPage.current page.liveView = FaceViewController() In main process Only active while running Contents.swift LiveView.swift import PlaygroundSupport import PlaygroundSupport let page = PlaygroundPage.current let page = PlaygroundPage.current page.liveView = FaceViewController() page.liveView = FaceViewController() In main process Only active while running Contents.swift LiveView.swift import PlaygroundSupport import PlaygroundSupport let page = PlaygroundPage.current let page = PlaygroundPage.current page.liveView = FaceViewController() page.liveView = FaceViewController() In main process Separate process Only active while running Contents.swift LiveView.swift import PlaygroundSupport import PlaygroundSupport let page = PlaygroundPage.current let page = PlaygroundPage.current page.liveView = FaceViewController() page.liveView = FaceViewController() In main process Separate process Only active while running Running all the time Main Process (Contents.swift) import PlaygroundSupport let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { let message: PlaygroundValue = .string("Knock, knock!") proxy.send(message) } Main Process (Contents.swift) import PlaygroundSupport let page = PlaygroundPage.current if let proxy = page.liveView as? PlaygroundRemoteLiveViewProxy { let message: PlaygroundValue = .string("Knock,

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    196 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us