Chapter 4
Advanced Swift Programming
This chapter will cover more advanced recipes that you can use when creating applications using Swift. Recipes in this chapter will cover the following topics:
- Writing Closures
- Writing Trailing Closures
- Overloading the Equality Operator
- Checking for Reference Equality
- Implementing Generic Functions
- Implementing Generic Classes
- Working with Local Dates and Times
- Creating a Unit Test Project
- Writing a Unit Test
- Performance Testing with XCTest
- Creating Mock Objects for Testing
- Testing Asynchronous Code
4-1. Writing Closures
Problem
Your application needs to pass a function as a parameter to another function. For example, a method requires a callback function that is executed upon completion.
Solution ...
Get Swift Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.