This technique project is different to all the others so far. You see, I've already written all the code for you and I'm giving you a working app. Sure it has a few bugs here and there, but it's not too bad. Well, OK: perhaps it's full of bugs, and perhaps this whole project is about showing you how to find and fix those bugs!
We're going to be using a tool called Instruments. It ships as part of Xcode, and is responsible for profiling your app. "Profiling" is the term used when we monitor performance, memory usage and other information of an app, with the aim of improving efficiency.
I'm not going to make you a master of Instruments, but I can at least show you how it helps you find problems with your code. Plus, along the way you'll learn a few extra bits about how iOS works, including shadows, image caching, cell reuse and more.
Please note: it's recommended you use physical devices when profiling your apps because their performance characteristics are very different from those of the iOS simulator. It's not required, just strongly recommended. If you're going to choose a device, I recommend choosing the least powerful device you support so that you can be sure it still works OK. Trust me: if your code works quickly enough on an ancient iPad, it will run like lightning on an iPad Pro.
You should download the source code for this project from GitHub (https://github.com/twostraws/HackingWithSwift) then modify it as we go. When you open the project, change the the build destination to be your iOS device if you have one handy, otherwise use the iPhone 8 simulator.
Test your Swift today
Think you know Swift? My book Swift Coding Challenges will put your Swift skills to the test – it's perfect for job interviews and more!