title: Call to main actor-isolated instance method XXX in a synchronous nonisolated context
body: <p>I am trying to add an async do/catch/defer action to a UIButton. However, if I just call a method in the defer block, I get <code>Call to main actor-isolated instance method XXX in a synchronous nonisolated context</code> error. The workaround I found is to wrap it in another <code>Task</code> block, like the following. Just want to check if this is the correct way to do it? It'd be good if someone can explain what that error message actually says.</p>
  <pre><code>@objc private func post(_ sender: UIButton) {
      Task {
          // defer { dismiss(animated: true) } -- Doesn't work
          defer { Task { await dismiss(animated: true) } }
          do {
              try await doSomethingAsync()
          } catch {
              print(error)
          }
      }
  }
  </code></pre>