You may be familiar with the map(_:) method in Swift that can be called on arrays. This allows you to pass in a closure that gets executed on each item of the array, transforming the element in some way. The result is a new array of transformed items. It’s also possible to map over a dictionary using the same syntax. Read more…
How to Check Whether a Device Has FaceID or TouchID
If your app uses biometrics, you’ll likely want to know whether TouchID or FaceID is available on a user’s iOS device. For example, you may want to show a button on the login screen that has the appropriate icon for whichever biometrics capability the user has. Or you may want to set the correct text in your app settings so it shows “FaceID” or “TouchID”. Read more…
The Try Keyword and its Variations in Swift
The try keyword and its variations of try! and try? are used before function calls which have the possibility of throwing an error. The kind of function that can do this is known as a “throwing function”. It contains throws after the function name, but before the return type. We’ll explore the try keywords below and look at their differences. Read more…
Include Custom Text in Swift Date Format
When formatting dates in Swift, occasionally we need to include custom text within the resulting date string. How is that done without creating conflicts with date formatting characters? We can use single quotes (' ') to escape the text we want to add. Read more…
Using Custom Properties in Swift Decodable Objects
The Decodable protocol makes it extremely simple to parse JSON from the web. However, one of the things I ran into recently was needing to have a property in one of my Decodable model objects that was not in the JSON I would be fetching. Having that property in the object would cause an error. There are a couple of ways to address this. Read more…
- Page 2 of 2
- 1
- 2