Protocols in Swift Explained

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:41 am | 4-min read

Working with protocols is one of Swift’s most fundamental features. With protocols you define “rules” that an adopting class must conform to. This principle lets you write decoupled, modular and extensible Swift code. In this tutorial you’ll learn how to work with protocols, and why they are useful for practical iOS development. We’ll touch on Swift principles that rely on protocols to function, such as dependency injection and delegation. And of course, this tutorial has plenty [...]

Read More

Scheduling Local Notifications with Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:41 am | 5-min read

How do you send and receive local notifications in your iOS app? In this tutorial, you’ll learn how to build local notifications into your iOS app with Swift. We’ll focus on: How to schedule and handle local notifications Sensibly structuring the local notification code Asking the user permission to send local notifications How to set up triggers for local notifications How to handle foreground and background notifications We’ll also take a few intermezzo’s to discuss idempo [...]

Read More

Error Handling with Try and Catch in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:41 am | 5-min read

You use do, try, catch and throw to handle errors and exceptions in Swift. Error handling gives you greater control over unexpected scenarios that might occur in your code, like a user that inputs a wrong account password. In this tutorial, we’ll discuss: Why catching (and throwing) errors is important Syntax for handling errors in Swift, with do try catch How to throw and rethrow errors and exceptions How to create your own Error types (and why) When to convert errors to optional va [...]

Read More

Dependency Injection in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:41 am | 5-min read

Dependency Injection sounds complex, but it’s actually a surprisingly simple concept. In this tutorial, you’ll learn how dependency injection works. Understanding dependency injection (DI) will greatly improve your code quality and productivity as a Swift developer. Many software design principles, like Don’t Repeat Yourself and SOLID, have one thing in common: they make your code more maintainable by making it modular. Instead of creating one big pile of code, you create separate your [...]

Read More

Storing Data with NSCoding and NSKeyedArchiver

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:41 am | 5-min read

You can use NSCoding and NSKeyedArchiver to save and load simple data objects with Swift. It’s perfect for scenarios when you don’t need a more complex tool, like Core Data or Realm. In this tutorial, we’ll discuss: How to store and retrieve data objects with NSKeyedArchiver Why NSCoding is an important component in iOS development How NSKeyedArchiver compares to components like Codable Essential app development principles like serialization A whole lot of fun code examples for y [...]

Read More

Most Popular Posts