Coding at Home: July 8th, a new challenge!

Join us today at 4pm Irish time for a new challenge!

We’re testing out your ability to switch it up this week, and we’ll be going live at 4pm today.

Today’s session @ 4pm

We’re going to start a super fun series today with Sensor Arcade!

I love this playground because it shows us what amazing capabilities we have in our hands with the iPad.

We start off writing a touch event handler to handle when and where a user puts their finger on the screen.

This is an intermediate playground, so it definitely helps if you’ve gone through the Everyone Can Code Puzzles lessons, first.

But if you’ve been following along with the Lights, Camera, Code playground or the Sonic Workshop sessions you should be well able for this.

Game-based learning

A huge motivation for working on the code in these next few sessions will be all about the games. We’ll write code to practice and then play our own games, using the different sensors on the iPad — the touch screen, microphone, light sensor in the camera — as input devices and controllers.

And the great thing about coding our own games is we can see and feel how our code affects the way the game is played.

I can’t wait to get cracking on this one. See you at 4pm!

Coding at Home: Revisiting an Old Swan Friend

Join us today at THREE P.M., Irish time, when we revisit an old friend!

Note the later time, we’ll see you at 3, Irish time, instead of 1.

Swan’s Quest, Revisited

So now that we’ve finished Sonic Workshop, we’re going to revisit an old friend today.

With our newly-minted knowledge about closures, we’re going to see how they apply to Chapter 2 of Swan’s Quest.

You can either work with your existing copy of Swan’s Quest: Chapter 2, or download a new copy from our playground feed for WWDC.

We’ll talk about those pesky DispatchQueues and Timers and hopefully they’ll make a lot more sense.


Once we revisit old times, we’ll move right on to one of my favorite playgrounds.

Sensor Arcade takes advantage of all the sensors we have built into our iPad that we take for granted.

We’ll play with touch handlers, like we did in Sonic Workshop. We’ll also play with light handlers, which uses properties of the camera to tell us about brightness levels in the room around us.

I can’t wait to show you around this playground and see what we can do with Swift!

See you at 3pm, Irish time!

Coding at Home: July 6th, Sonic Workshop #5

Join us today at 1pm for some more Sonic Workshop!

We’re nearly done with Sonic Workshop and we have learned a ton.

We added a new function that will create a crystal that plays sound in a loop. We’ve explored closures in a few different forms. That’s been a lot of work.

Today’s session

Today we’ll add some visual flair to our auditory masterpiece, and then we’ll use some pre-built functions to build out an entire musical masterpiece!

We’re going to add a call to a function called addCaveGlitter, does it get better than that?

So we’re going to customize the heck out of this playground as a reward for all the hard work.

Revisiting the Swan

Remember the Swan’s Quest? Sure you do, it was only a little while ago.

We’re going to go back and have a quick look at those playgrounds, now that we have the Sonic Workshop under our belts.

In particular, we’re going to look at Swan’s Quest, Chapter 2, and see if what we just learned can help us better understand the challenge of the swan!

So if you want to follow along, and even start fresh, open up that Chapter 2 playground from our WWDC playground feed!

See you today at 1pm!

Coding at Home: July 3rd, Sonic Workshop #4

Join us today for some more functions at 1pm, Irish time!

Super coders!

You guys have written some amazing code at this stage! I hope you had some time to play around with that touch moved code. We were using a bit of math to figure out where the x position of our touch was, then we divided that by the width of our graphic. This was just to get us a number to plug into the Color initializer. And it was a little bit to show off how we get the updated position of the user’s finger on the graphic.

We fed that color into the setTintColor method on our graphic to visually show how often that new handler we set gets called.

Today’s session

Today we’re going to add a touch handler for when someone presses on the graphic.

We’ve done this before in previous pages. But this time we’ll use some of the other functions defined by the playground for playing music.

We’ll spend a lot of time customizing the behavior of our graphic when we tap on it. And we’ll also spend some time exploring all those messages to our onTouchMovedHandler. Maybe we can come up with some other use for them?

You can get as creative as you like with your function names, you just may sacrifice your sanity with some names.

We’ll see you at 1pm!

Coding at Home: July 2nd, Sonic Workshop #3

Come and join us in the Sonic Workshop today at 1pm, Irish time!


Yesterday we spent some time writing some code in a function in a shared file.

This comes in useful, like we said, when you want to do the same tasks over and over again.

Today’s session

In the previous page we had a function pre-written for us. Today we’re going to write our own. Like yesterday’s function, ours will also return a Graphic to place in the scene.

In our createCrystal function we return a Graphic by using a dash and a greater than sign, followed by the type we return. Like so:

public func createCrystal(image: Image, sound: SonicSound) -> Graphic  {

We’ll want to come up with a good, descriptive name for our new function so it makes sense when we use it in code, later.

This requires a bit of thought up front, but it will pay off when we can come back to our code and understand it without too much trouble.

We’ll also get introduced to a new wrinkle in the syntax for closures. Remember, closures are effectively unnamed functions. With functions, we can define parameters you can pass in, as well as a return type.

In the closure we use for the setOnTouchMovedHandler we’ll see in this session we’ll show you how to specify a parameter for a closure and what that does to what a closure looks like.

Like many things with code, there are many ways to write closures. We’ll try to use the most clear way possible to avoid confusion and make our code readable.

Let’s get coding! We’ll see you at 1pm!

Coding at Home: July 1st, Sonic Workshop #2

We’re back with Sonic Workshop today at our usual time of 1pm, Irish time, join us!

Coding with Closures

Yesterday was a big session. We were introduced to closures and learned a little bit about what they are (unnamed functions, in a few words) and when we would use them. And how.

The closure we wrote had no parameters, so it’s one of the easier forms to use (and write).

You might remember, if you’re not scarred (😉), from the later chapters in the Swan’s Quest playgrounds, that we used closures a bit.

When we got to the Timer code we scheduled a timer and wrote some code to be run every so many seconds. We’re going to learn how to write code like that soon!

Today’s session

Today we’re going to go back to functions. Back in the Everyone Can Code Puzzles days, we learned a lot about functions.

In today’s lesson we’ll write functions that return values. This means we do some work in the body of the function and get give some sort of feedback back to the code calling it.

We’ll also write functions with parameters. This lets us write code that can easily be re-used. If you hang around programming long enough, you’ll realize that’s one of our Holy Grails.

We’ll put our function in some shared code, so it will live with us for the rest of the playground pages.

So come along with us at 1pm, Irish time! Or follow along later. We have a new Sonic Workshop landing page, which shows you videos from the Sonic Workshop YouTube playlist. All the videos in this latest series will show up there.

Coding at Home: June 30th, Sonic Workshop

Join us today for some more coding at 2pm, Irish time!

Note the adjusted time — 2pm!

More playgrounds!

Today we’re going to diverge from the expected plan. Instead of resuming the Augmented Reality playground, we’re going to start a new playground.

Inspired by the Swan’s Quest sessions at WWDC, we’re going to look at their inspiration: Sonic Workshop.

Sonic Workshop is designed very like the Lights, Camera, Code playgrounds we’ve used recently.

So you should feel pretty at home with this one!

It’s an intermediate playground and will explain some of the concepts we encountered in Swan’s Quest.

I can’t wait to get you guys making some sound!

See you at 2!

Coding at Home: WWDC Special #4, the Wrap-Up

Join us today at 1pm when we talk about the final chapter of Swan’s Quest!

The Quest

So Swan’s Quest ended on Friday with one more performance for the swan in Swan’s Quest, Chapter 4.

We added the the playground book for Chapter 4 to our special WWDC feed for ease of use putting it on your iPad.

We’ll spend a little bit of time talking about the final chapter today. The first chapter was an excellent reminder to make sure our apps are accessible, because there are all kinds of users out there.

We focused on playing notes and organizing our code to enable us to do so in a flexible and (relatively) easy to use manner in the last three chapters.

I’ve posted the code online (and will add it to the video description) for solving the puzzle for Chapter 4.

The last three challenges were designed for attendees of WWDC, who are typically professional software engineers who are doing this sort of thing for their day job. So if you’re still learning Swift with us, don’t be too frustrated. These playgrounds give us a nice level of knowledge to aspire to, especially if you’re into music. But don’t forget, most of this code is based on fundamentals you’ve just learned.

Other WWDC goodies

We’ll talk briefly about WWDC and some of the other fun sessions they had this year.

And I’ll also show you one little feature for Reality Composer on the iPad I didn’t realize was there (thanks to @PaulHamilton8!).

This will let us add images to our Reality Composer scenes.

It was an exciting week of great content from the engineers at Apple. We hope you enjoyed our little diversion to Swan’s Quest!

I’ll see you at 1pm, Irish time!

Coding at Home: WWDC Special #3

Join us today for our live coding session at 1pm, Irish time!

Today’s session

Today we’re going to explore Swan’s Quest: Chapter 3, but I’m not quite sure the material lends itself to our session. We’ll see.

There’s some music theory thrown in, subdivision of notes, pitches, frequencies… It’s a little bit Greek to me. But we can take a poke around the playground in the beginning, anyway, and see if we can make head or tails of it.

!! Image from Swan’s Quest: Chapter 3 WWDC20 Session

There are also Protocols, which is an interesting Swift feature, and enumerations, or Enums. This, again, is a little beyond the scope of what we’ve covered so far, but I hope we can make some of it clear.

As before, you can download the Swan’s Quest: Chapter 3 playground from The Code Hub WWDC Playground feed.


It might not be “or”, it might be “and.”

There was an awesome session yesterday called Create Swift Playgrounds content for iPad and Mac.

The playground book they used in that session was excellent, so we may talk a little bit about that playground book, which is now available in The Code Hub WWDC Playground feed.

We’ll see you at 1pm!

Coding at Home: WWDC Special #2

Join us today at 1pm for some more fun, playing with the new set of playgrounds from Apple, Swan’s Quest!

Swan’s Quest, Chapter 2


Have you seen the session for Swan’s Quest, Chapter 2?

It is an awesome playground and builds on the previous challenge, but boy oh boy, are we in deep!

There are some brand new concepts we haven’t covered yet, in our sessions. But we’re going to dive in, anyway, and try and explain and help you solve this new challenge.

First, you’ll want to grab the latest playground from the playground feed we mentioned yesterday.

There’s no VoiceOver setup this time, today we’ll be working with sound, though.

What we’re almost certainly going to want to do is open up the Developer app, either on our iPad or on a Mac.

The Developer page for many sessions (including the Swan’s Quest ones we care about) has a tab bar near the top: Overview, Transcript, and Code.

We’re going to tap on the Code tab if we get stuck.

This tab includes all the code mentioned in the videos. You can copy the code and paste it right into your playground.

This playground uses some advanced stuff. In addition to more advanced audio stuff than we’ve played with, so far, in The Code Hub classes, it includes concepts like Timers, which have some interesting properties, and guard statements, which is a handy control mechanism in Swift.

We’ll talk about all of that stuff today on the session.

In these cases, where the content is that bit more difficult or maybe just something you’re not familiar with (yet), it helps sometimes to copy and paste in code someone insists will work, try it, run it, then play around with it. You can learn a lot by copying someone else’s code and then breaking it!

For the advanced

If you’re blazing ahead, congratulations!

I’ve added the blank Quest Create playground book in the feed, too, so you can grab that and add it to your iPad. It gives you a really interesting starting point for building your own adventure based off this code.

We’ll see you at 1pm, bring some popcorn, patience, and your coding pants!