Launching Swift Playground with Button Tap


(William Chapman) #1

In the “Learn to Code” Swift Playground, at the end of the Intro cut-scene which was developed using Hype, there is a “Start Coding” button which, when tapped, takes the student to the first Swift Playground page.

Can anyone shed some light on how this is done? Is there a hyperlink to the first playground, for example?

Thanks!


(Mark Hunte) #2

Can you provide more details please.

Like where are you seeing this “Learn to Code” and why do you think it was used using Hype…

Please provide links


#3

This is likely calling a JavaScript function which displays the next page. Each of these files can be downloaded to inspect the source code if you wish, but I don’t think I should be reverse engineering it. Here’s how you can download the individual books: http://ericasadun.com/2016/06/14/playgrounds-part-ii/

You can find the Hype documents within the contents of each playground book:

It was, we promise!


(Jonathan Deutsch) #4

It looks like they are using a ‘Go to URL…’ action with the value of @next and not setting it to open in a new window.


(William Chapman) #5

Yes! That’s it, exactly. To make a link that goes to another page in a Swift Playground, make an action on an object that does ‘Go to URL’ and have it link to @next or @previous without opening a new window.

Thank you very much folks!


(EmyJ) #6

Select File-> New Playground(name and iOS/OSX/tvOS). Choosing iOS will import UIKit, while OSX imports Cocoa. Third one will let you use tvOS as base environment.


The playground has main 4 areas editor, results sidebar, show console triangle and run button. The play button
The “play” button controls manual execution of the source and the button to the left of it will toggle display of the console.
Each time a Swift statement in entered into the editor, results will be displayed in the sidebar. The source editor is functioning and will show you code completion hints and syntax error too in real time.
Do refer these useful articles on Swift programming
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097
http://www.cestarcollege.com/blog/news-and-events/3-benefits-of-using-swift-programming/
https://en.wikipedia.org/wiki/Swift_(programming_language)