Swift’s foundation library provides a sorted(by:) function for sorting arrays. The areInIncreasingOrder closure needs to return true if the closure’s arguments are increasing, false otherwise. How to use the closure for sorting by multiple criteria? Let’s take a look at an example of sorting an...
DateFormatter is used for converting string representation of date and time to a Date type and visa-versa. Something to be aware of is that the conversion loses microseconds precision. This is extremely important if we use these Date values for sorting and therefore ending up with incorrect order....
It took a long time, I mean years, but it finally happened. I stumbled on a struct which had a property of the same type. .gist table { margin-bottom: 0; } This file contains hidden or bidirectional Unicode text that...
Testing network calls is a critical aspect of ensuring the reliability and stability of your iOS applications. We'll explore how to effectively test network calls in Swift using the URLProtocol API. With this guide, you will have powerful tools to ensure code quality.SetupWe will use a very simple...
Foundation framework has many useful implementations, that can make our life easier. One of them is Unit and Measurement APIs.Unit and MeasurementMeasurment is a struct that holds the value of the given Unit. Additionally, it can convert, add, subtract, and do other arithmetical operations on this...
As iOS developers, we frequently interact with various public and private REST APIs, some of which are reliable and well-established, while others may not be as reliable.In certain scenarios, we cannot guarantee that the received model will precisely match the expected type. Some APIs may return...