Inspired by some recent teacher questions via email and Twitter, I threw together some more advanced Swift Playgrounds.
Right now there are two of them. As Swift Playgrounds, they’re designed to run in the Playgrounds app on your iPad, so you can take your code on the go with you, or monkey around with them in the Playgrounds app on your Mac. Playgrounds is a great environment for tinkering with code and it just keeps getting better and better.
I split them into a separate feed from our normal playground feed because the original is aimed at beginners, learning to code. This new set of playgrounds comes with fewer instructions and tackles more complex material.
Add the feed from our playgrounds page, if you’re on an iPad. If you’re using Playgrounds on a Mac, you can select File > Add Subscription… and add this URL: https://www.thecodehub.ie/playgrounds/adventures/feed.json
The first playground tackles the @StateObject and ObservableObjects in SwiftUI, “the new hotness,” as my old boss would say.
In this playground, we use new files in the UserModule to create a model that will hold minutes for a timer (seconds, really)… we show you how to organize your code to keep the “model” in one place that you could use from multiple locations in your SwiftUI-based app.
UIView and Animation
The second playground shows off creating a UIView in code, making it the live view and animating an image view across the screen.
It’s a nice way to start playing with animation and checking out all the properties you can animate on a UIView.
More to Come
There are more to come, of course, this is just the start. Hopefully these playgrounds will give you an idea for what you can do with the Playgrounds app. Post-WWDC, I’m sure, we’ll have lots more goodies to explore all the fun new toys we have to play with.