From df2a3a5832c148553895f74f1273282662db4c18 Mon Sep 17 00:00:00 2001 From: Lou Franco Date: Wed, 14 Sep 2016 09:16:42 -0400 Subject: [PATCH] Update to iOS 10.0.1 Playgrounds --- README.md | 14 +++++++++----- .../Contents/Sources/Conversation.swift | 4 ++-- .../Contents/Sources/FaceAnimators.swift | 10 +++++----- .../Contents/Sources/FaceView.swift | 10 +++++----- .../Contents/Sources/FaceViewController.swift | 2 +- .../Contents/Sources/Utils.swift | 2 +- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d456810..a1c1891 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,20 @@ NOTE: The [TalkingToTheLiveView sample from WWDC](https://developer.apple.com/li The LICENSE.txt file is the original one from Apple. All of my commits are in the public domain. -As of 2016-Aug-07, the only way I can see to get a playground book to the iPad is via AirDrop. +## Change Log + +2016-Sep-14: Updated to iOS 10.0.1 + +2016-Aug-29: Still works with iOS 10 Beta 8 with no further changes + +2016-Aug-23: Updated to iOS 10 Beta 7 + +2016-Aug-07: the only way I can see to get a playground book to the iPad is via AirDrop. 1. Open Playgrounds on your iPad 2. AirDrop the .playgroundbook folder to the iPad 3. Follow instructions on the iPad (choose to AirDrop to Playgrounds) -2016-08-23: Updated to iOS 10 Beta 7 - -2016-08-29: Still works with iOS 10 Beta 8 with no further changes - ## Original README follows This Playground Book demonstrates how to talk to the always-on live view process from the main process running the code in the editor. diff --git a/Talking To The Live View.playgroundbook/Contents/Sources/Conversation.swift b/Talking To The Live View.playgroundbook/Contents/Sources/Conversation.swift index df50ef5..bfc3fc2 100644 --- a/Talking To The Live View.playgroundbook/Contents/Sources/Conversation.swift +++ b/Talking To The Live View.playgroundbook/Contents/Sources/Conversation.swift @@ -44,11 +44,11 @@ class Conversation { let oldState = currentState currentState = nextState - transitionObserver?(oldState: oldState, newState: currentState) + transitionObserver?(oldState, currentState) } /// Block that is called whenever the state transitions. - var transitionObserver: ((oldState: State, newState: State) -> ())? = nil + var transitionObserver: ((_: State, _: State) -> ())? = nil } extension Conversation.State { diff --git a/Talking To The Live View.playgroundbook/Contents/Sources/FaceAnimators.swift b/Talking To The Live View.playgroundbook/Contents/Sources/FaceAnimators.swift index d909d42..a262720 100644 --- a/Talking To The Live View.playgroundbook/Contents/Sources/FaceAnimators.swift +++ b/Talking To The Live View.playgroundbook/Contents/Sources/FaceAnimators.swift @@ -27,7 +27,7 @@ protocol FaceAnimator: class { func start() /// Requests to stop the animator. Calls the `doneCallback` when the animator is really done. - func stop(doneCallback: () -> ()) + func stop(doneCallback: @escaping () -> ()) } @@ -46,7 +46,7 @@ class NeutralFaceAnimator: FaceAnimator { planToNod() } - func stop(doneCallback: () -> ()) { + func stop(doneCallback: @escaping () -> ()) { running = false if nodding { whenDoneNodding = doneCallback @@ -130,7 +130,7 @@ class LaughingFaceAnimator: FaceAnimator { executeAnimation() } - func stop(doneCallback: () -> ()) { + func stop(doneCallback: @escaping () -> ()) { if running { whenDoneRunning = doneCallback } @@ -210,7 +210,7 @@ class ConfusedFaceAnimator: FaceAnimator { executeAnimation() } - func stop(doneCallback: () -> ()) { + func stop(doneCallback: @escaping () -> ()) { running = false if blocking { whenDoneRunning = doneCallback @@ -295,7 +295,7 @@ class AnnoyedFaceAnimator: FaceAnimator { executeAnimation() } - func stop(doneCallback: () -> ()) { + func stop(doneCallback: @escaping () -> ()) { running = false if blocking { whenDoneRunning = doneCallback diff --git a/Talking To The Live View.playgroundbook/Contents/Sources/FaceView.swift b/Talking To The Live View.playgroundbook/Contents/Sources/FaceView.swift index e6e419b..2cf5bab 100644 --- a/Talking To The Live View.playgroundbook/Contents/Sources/FaceView.swift +++ b/Talking To The Live View.playgroundbook/Contents/Sources/FaceView.swift @@ -45,7 +45,7 @@ class FaceView: UIImageView { func stop(completion: (() -> ())? = nil) { currentFaceAnimator?.stop(doneCallback: {completion?()}) currentFaceAnimator = nil - nextFaceAnimatorRequest?.callbackWhenStarted?(skipped: true) + nextFaceAnimatorRequest?.callbackWhenStarted?(true) nextFaceAnimatorRequest = nil } @@ -53,9 +53,9 @@ class FaceView: UIImageView { /// is completed. `completion` is called back when this happens with `skipped` /// set to `true` if another state transition was requested in the meantime and /// this emotion was skipped. - func moveToEmotionWhenReady(newEmotion: Emotion, completion: ((skipped: Bool) -> ())? = nil) { + func moveToEmotionWhenReady(newEmotion: Emotion, completion: ((_: Bool) -> ())? = nil) { if let next = nextFaceAnimatorRequest { - next.callbackWhenStarted?(skipped: true) + next.callbackWhenStarted?(true) } let animator = makeAnimator(forEmotion: newEmotion) @@ -66,7 +66,7 @@ class FaceView: UIImageView { guard let next = self.nextFaceAnimatorRequest else { return } self.currentFaceAnimator = next.animator self.currentFaceAnimator?.start() - next.callbackWhenStarted?(skipped: false) + next.callbackWhenStarted?(false) self.currentEmotion = next.emotion } @@ -102,7 +102,7 @@ class FaceView: UIImageView { struct FaceAnimatorRequest { let animator: FaceAnimator let emotion: Emotion - let callbackWhenStarted: ((skipped: Bool) -> ())? + let callbackWhenStarted: ((_: Bool) -> ())? } } diff --git a/Talking To The Live View.playgroundbook/Contents/Sources/FaceViewController.swift b/Talking To The Live View.playgroundbook/Contents/Sources/FaceViewController.swift index bcc8e43..7d1de9b 100644 --- a/Talking To The Live View.playgroundbook/Contents/Sources/FaceViewController.swift +++ b/Talking To The Live View.playgroundbook/Contents/Sources/FaceViewController.swift @@ -256,7 +256,7 @@ public class FaceViewController: UIViewController, UIGestureRecognizerDelegate { } } - private func addJokePattern(_ pattern: JokePattern) { + func addJokePattern(_ pattern: JokePattern) { // First check to see if we already have the pattern registered. // The setup/punchline pair must be unique. // Replace any existing patterns that match the same setup/punchline. diff --git a/Talking To The Live View.playgroundbook/Contents/Sources/Utils.swift b/Talking To The Live View.playgroundbook/Contents/Sources/Utils.swift index 4dba32f..1c4f79e 100644 --- a/Talking To The Live View.playgroundbook/Contents/Sources/Utils.swift +++ b/Talking To The Live View.playgroundbook/Contents/Sources/Utils.swift @@ -15,7 +15,7 @@ public func flipACoin() -> Bool { /// Convenience wrapper around DispatchQueue.main.after that waits for /// `interval` seconds before executing the `work` block. -public func after(_ interval: TimeInterval, work: () -> ()) { +public func after(_ interval: TimeInterval, work: @escaping () -> ()) { let time: DispatchTime = DispatchTime.now() + .milliseconds(Int(interval * 1000.0)) DispatchQueue.main.asyncAfter(deadline: time) { work()