Skip to content

Instantly share code, notes, and snippets.

@T1T4N
Created February 3, 2025 00:01
Show Gist options
  • Save T1T4N/a14e2220422d9ab363fed8454c3eb094 to your computer and use it in GitHub Desktop.
Save T1T4N/a14e2220422d9ab363fed8454c3eb094 to your computer and use it in GitHub Desktop.
Fix for "Sending 'self' risks causing data races" in Swift 6
// 1. Decorate the class itself with e.g. @MainActor
// 2. If that isn't possible, here is an example workaround:
deinit {
nonisolated(unsafe) let obj = self
MainActor.assumeIsolated {
obj.dismiss(animated: false)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment