NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

What you learned

These three projects were a mixed bag in terms of difficulty: although Safari extensions are clearly a bit of a wart in Apple’s APIs, it’s still marvelous to be able to add features directly to one of the most important features in iOS. As for the Fireworks Night project, I hope it showed you it doesn’t take much in the way of graphics to make something fun!

You also learned about local notifications, which might seem trivial at first but actually open up a huge range of possibilities for your apps because you can prompt users to take action even when your app isn’t running.

The best example of this is the Duolingo app – it sets “You should practice your language!” reminders for 1 day, 2 days, and 3 days after the app was most recently launched. If you launch the app before the reminders appear, they just clear them and reset the timer so you never notice them.

Here’s a quick reminder of the things we covered:

  • How to make extensions for Safari by connecting Swift code to JavaScript. Getting the connection working isn’t too easy, but once it’s set up you can send whatever you want between the two.
  • Editing multi-line text using UITextView. This is used by apps like Mail, Messages, and Notes, so you’ll definitely use it in your own apps.
  • You met Objective-C’s NSDictionary type. It’s not used much in Swift because you lose Swift’s strong typing, but it’s occasionally unavoidable.
  • We used the iOS NotificationCenter center class to receive system messages. Specifically, we requested that a method be called when the keyboard was shown or hidden so that we can adjust the insets of our text view. We’ll be using this again in a later project, so you have ample chance for practice.
  • The follow() SKAction, which causes a node to follow a bezier path that you specify. Use orientToPath: true to make the sprite rotate as it follows.
  • The color and colorBlendFactor properties for SKSpriteNode, which let you dynamically recolor your sprite.
  • The motionBegan() method, which gets called on your view controllers when the user shakes their device.
  • Swift’s for case let syntax for adding a condition to a loop.
  • The UserNotifications framework, which allows you to create notifications and attach them to triggers.
Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.