The app is finished, but really your work is about to begin: I've given you all the code you need, but it's down to you to provide some meaningful patter to convince your friends! See "Polishing your patter" below for some example patter to get you started, but first give the app a quick try to make sure it all works.
To get started, run the app on your phone, then run it on your Watch. Note that installing apps and launching apps are both quite slow on Apple Watch, so make sure you prepare ahead of time. Once the Watch app is running, remember that it will go to sleep in 70 seconds unless you stop it, and when the Watch sleeps you won't get any haptic taps. The easiest thing to do is very gently rotate the Digital Crown every 30 seconds or so, just to be sure.
So, the app is complete and you've learned all about
CAEmitterLayer, card flip effects,
perform(), 3D Touch and more - good job! If you want to try taking the app further, try implementing the
sessionWatchStateDidChange() method in ViewController.swift to detect when the Watch goes to sleep – if you make your phone play a brief but innocuous sound, it would alert you to wake your watch.
If you're looking for something more advanced, try adding a hidden button to the Watch user interface that enables "always win mode" – i.e., every card that gets tapped will be the star. Your patter can then be, "I promise it's not a trick, in fact I can even transfer my psychic power to you!" and watch as your friend suddenly finds the star every time.
And if you’re keen to delve more into watchOS development, I wrote a whole book teaching you how to make watchOS apps: Hacking with watchOS.
Patter is verbal misdirection: what you say to your friends to confuse them while they are trying to figure out the trick. At the very least, you should explain to your friend how the cards work: there are eight cards with different shapes on, but only one has a green star. Let your friend try finding the card by hand, to prove the set up is real. Lucky people will guess the star correctly; very lucky people will guess twice in a row; but it's almost impossible that someone will get the answer right three times in a row - that's where you come in!
The easiest way to get started with the trick is by putting your finger down over one card, then dragging it slowly over the other cards. Note: don't tap the cards, because that will turn one of them over. Instead, slide your finger over them as if you're feeling for – ahem – psychic vibrations.
When you've done the trick correctly once or twice, your doubting friend will almost certainly think that there's some secret signal on the screen that is alerting you to the correct card, or perhaps you're performing some sort of gesture on the screen that triggers the star. In this situation, up the ante: tell them you can do the trick without even seeing the screen. In fact, you can do it without even touching the screen - they can do all the touching for you.
This works in just the same way, except now your friend is the one stroking their finger across the screen. Just wait for your Watch to tap your wrist, then say something like "go back to that card - I felt something there..."
Remember, misdirection is key. So, don't tap the right answer as soon as your phone vibrates. Say something like "hmm... this card feels really warm... let me try some others first." Or go to one of the cards nearby and say "this card feels warm, but not as warm as the previous one..."
Finally, once you've fooled everyone and had your fun, let them in on the joke - after all, if you can't have fun, why bother?
SPONSOR Tired of wasting time debugging your Swift app? Instabug’s SDK is here to help you minimize your debugging time by providing you with complete device details, network logs, and reproduction steps with every bug report. All data is attached automatically. It only takes a line of code to setup. Get started for free.
One of the most effective motivators of success is sharing your progress with other people – when you tell folks what you're doing and what you've learned, it encourages you to come back for more, which in turn will help you reach your app development goals faster.
So, now that you've done all the hard work it's time to share your success: tell folks that you've completed this project, either by clicking the button below to start composing a tweet, or by writing your own message from scratch. This will definitely encourage you to keep learning, but it will also help other folks discover my work – thank you!
Paul Hudson is the creator of Hacking with Swift, the most comprehensive series of Swift books in the world. He's also the editor of Swift Developer News, the maintainer of the Swift Knowledge Base, and Mario Kart world champion. OK, so that last part isn't true. If you're curious you can learn more here.