Swift has a lot of different syntaxes that are not necessarily used on a daily basis and can be difficult to remember. There are a great series of websites that summarize many of these Swift nuances, as well as date formatting and Swift's FormatStyle
and ParseableFormatStyle
functions.
Most of these sites have primary domain names that are not safe for work, but I'll be linking to the gosh darn alternative names. If you're an adult, feel free to bookmark the explicit link. 😄
Easy Skeezy Date Formatting for Swift and Objective-C
NSDateFormatter.com has a large list of examples for various date formatting, a real-time format string playground, and a really great summary of localization-aware date handling.
If case let Syntax
The if case let
abbreviated form of switch is always confusing. You'll encounter it when using enumerated cases with associated values. GoshDarnifCaseLetSyntax.com gives you a bunch of examples of how to use it correctly.
How Do I Declare a Closure in Swift?
There are a lot of different ways to write closures in Swift and GoshDarnClosureSyntax.com provides examples for many of the typical cases.
GoshDarnClosureSyntax.com (Github)
How Do I Write Multiple Trailing Closures in Swift?
GoshDarnMultipletrailingClosureSyntax.com provides examples of how to specify multiple trailing closures. You should definitely be familiar with how "How Do I Declare a Closure in Swift?" before referring to this site.
Unfortunately, this is the one site that isn't available over a secure HTTPS connection, so Safari (rightly) throws up a warning and you'll need to jump through some hoops. I'd suggest visiting Github and downloading a version to your local file system and creating a bookmark to it there.
GoshDarnMultipletrailingClosureSyntax.com (Github)
Format Styles In Excruciating Detail
GoshDarnFormatStyle.com is absolutely loaded with almost everything you could need for using FormatStyle
and it's all in one place.
It covers the numeric styles (number, percent, and currency), single date styles (including relative dates/times), date ranges, duration, measurements, list styles (automatically inserting a localized "and" or "or" and formatting an array of data), localized person name formats, byte counts (bytes, kilobytes, memory and file formats), and URL output formatting.
On top of all that, it provides information on writing your own format style and discusses SwiftUI's integration with FormatStyle
.
GoshDarnFormatStyle.com (Github)
Those are the sites that I keep in a folder in my Favorites tabs and refer to more than any others. All but one have GitHub repos available (linked in each case) so you can fork them, submit modifications, and generally be good people.
I'd love to hear your comments. Did I miss any references that are up to date? Feel free to reach out to me at @sanguish on Mastodon.