My app uses the following view controller with an IBAction
.
When the action is triggered by some button, the button is disabled, and some background processing is started.
When background processing is finished, the button is enabled again, which has to be done on the main thread.
final class DebugViewController: UIViewController {
button.isEnabled = false
// …
@IBAction func action(_ sender: Any) {
// …
Task {
// some background processing
DispatchQueue.main.async {
self.button.isEnabled = true
}
}
// …
}
}
During a build, the following warning is shown at the statement self.button.isEnabled = true
:
Capture of 'self' with non-sendable type 'DebugViewController' in a `@Sendable` closure
I could avoid this warning by declaring the DebugViewController as
final class DebugViewController: UIViewController, @unchecked Sendable {
However, when I analyze instead of build the code, I get now the following error at this line:
Redundant conformance of 'DebugViewController' to protocol 'Sendable'
Thus I am a little confused:
UIViewController
Sendable
, as the "Redundant conformance" error suggests?And eventually, how to do it correctly?
This was apparently a bug in Xcode 13.3 Beta 2. In the released Version 13.3 (13E113), no warning is shown.