Project 29 was a serious game with a lot going on, not least the dynamically rendered buildings with destructible terrain, the scene transitions and the UIKit/SpriteKit integration.
And in project 30 we took our first steps outside of Xcode and into Instruments. I could write a whole book on Instruments, partly because it’s extremely powerful, but also because it’s extremely complicated. As per usual, I tried to cherrypick things so you can see useful, practical benefits from what I was teaching, and certainly you have the skills now to be able to diagnose and result a variety of performance problems on iOS.
Here are some of the things you learned in this milestone:
resignFirstResponder()
on a text view. (And remember: it also works on text fields.)UIApplication.willResignActiveNotification
notification.LAContext
from the LocalAuthentication framework to require Touch ID authentication.stride()
function to loop across a range of numbers using a specific increment, e.g. from 0 to 100 in tens.usesPreciseCollisionDetection
to make collisions work better with small, fast-moving physics bodies.presentScene()
method and passing in a transition effect. We’ll be using this again in project 36, so you’ll have ample time to practice transitions..clear
to erase parts of an image. Once that was done, we just recalculated the pixel-perfect physics to get destructible terrain.layer.shadowRadius
and other properties – and particularly how to use the layer.shadowPath
property to save shadow calculation.dequeueReusableCell(withIdentifier:)
so that iOS can re-use cells rather than continually creating new ones.UIImage(named:)
initializer has an automatic cache to help load common images. When you don’t need that, use the UIImage(contentsOfFile:)
initializer instead.SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.