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…