Skip to content

Commit

Permalink
Update to iOS 10.0.1 Playgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
loufranco committed Sep 14, 2016
1 parent 5824b7c commit df2a3a5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
14 changes: 9 additions & 5 deletions README.md
Expand Up @@ -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.
Expand Down
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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 () -> ())

}

Expand All @@ -46,7 +46,7 @@ class NeutralFaceAnimator: FaceAnimator {
planToNod()
}

func stop(doneCallback: () -> ()) {
func stop(doneCallback: @escaping () -> ()) {
running = false
if nodding {
whenDoneNodding = doneCallback
Expand Down Expand Up @@ -130,7 +130,7 @@ class LaughingFaceAnimator: FaceAnimator {
executeAnimation()
}

func stop(doneCallback: () -> ()) {
func stop(doneCallback: @escaping () -> ()) {
if running {
whenDoneRunning = doneCallback
}
Expand Down Expand Up @@ -210,7 +210,7 @@ class ConfusedFaceAnimator: FaceAnimator {
executeAnimation()
}

func stop(doneCallback: () -> ()) {
func stop(doneCallback: @escaping () -> ()) {
running = false
if blocking {
whenDoneRunning = doneCallback
Expand Down Expand Up @@ -295,7 +295,7 @@ class AnnoyedFaceAnimator: FaceAnimator {
executeAnimation()
}

func stop(doneCallback: () -> ()) {
func stop(doneCallback: @escaping () -> ()) {
running = false
if blocking {
whenDoneRunning = doneCallback
Expand Down
Expand Up @@ -45,17 +45,17 @@ class FaceView: UIImageView {
func stop(completion: (() -> ())? = nil) {
currentFaceAnimator?.stop(doneCallback: {completion?()})
currentFaceAnimator = nil
nextFaceAnimatorRequest?.callbackWhenStarted?(skipped: true)
nextFaceAnimatorRequest?.callbackWhenStarted?(true)
nextFaceAnimatorRequest = nil
}

/// Request to transition the animator to the new emotion after the current
/// 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)
Expand All @@ -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
}

Expand Down Expand Up @@ -102,7 +102,7 @@ class FaceView: UIImageView {
struct FaceAnimatorRequest {
let animator: FaceAnimator
let emotion: Emotion
let callbackWhenStarted: ((skipped: Bool) -> ())?
let callbackWhenStarted: ((_: Bool) -> ())?
}

}
Expand Up @@ -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.
Expand Down
Expand Up @@ -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()
Expand Down

0 comments on commit df2a3a5

Please sign in to comment.