See also macOS

General resources




Universal Links

Preflight possible universal links before opening SFSafariController

Before you open a URL in SFSafariController or any other browser, you should check if it’s a universal link,
and if so, open it in the respective native app instead.
It’s a good way to improve the user experience since SFSafariController will not trigger universal links on open.

let url = URL(string: "")!, options: [.universalLinksOnly: true]) { (success) in
    if !success {
        // not a universal link or app not installed
        let vc = SFSafariViewController(url: url)
        self.present(vc, animated: true)

iOS App Subscriptions

iOS Simulator

Push Notifications

How expensive is DateFormatter?

The key take away from all these stats are:

  1. DateFormatter is expensive to create.
  2. DateFormatter is expensive to change.
  3. Subsequent use of string(from: Date) is cheap.
  4. Subsequent use of date(from: String) is not cheap.

Wrangling Time: A Brief Explainer/Rant About Date Math

This is slightly misleading, though. Despite what the preview shows, Date has no concept of days, months, years, any of that stuff. It deals solely with time, and more specifically, the number of seconds that have passed since midnight of 1 January 2001, in UTC.


Here’s a screenshot from the Health app, showing my step counts for the day of June 8, 2017. It was a fairly active day, as I got in a bit over 20,000 steps. The distribution of those steps, though, feels a bit off. It reads like I was up walking all night, and then asleep throughout the day, and scrolling around a bit, that’s the story for the rest of the week too. I don’t remember spending the week that way.

As it happens I was in San Jose attending WWDC at the time, which has a -12:30 time difference with India , and as a result all of my health data from that trip appears time-shifted.


Going back to how Date works, it doesn’t model the actual clock time but rather a fixed point in time that can be interpreted in any time zone. And so what’s happening here is that the data is being interpreted as if it happened in my current time zone, which is the default time zone that Calendar and DateFormatter use.

And as such, a Date alone isn’t sufficient for modelling historical data, or at least personal historical data: You need time zone information too.

Tags: platform   ios  

Last modified 03 May 2022