#Xcode #ios #swiftlang question:
Given the WCSession API function
```swift
func sendMessage(
_ message: [String : Any],
replyHandler: (([String : Any]) -> Void)?,
errorHandler: ((any Error) -> Void)? = nil
)
```
I expected this to work.
```swift
_@MainActor
final class Something: NSObject, WCSessionDelegate {
func sendSomeData(someValue: SomeType) {
// build a plist using someValue
session.sendMessage(["Key": someValuePlist]) { response in
// process the response here
} errorHandler: { error in
// process any error here
}
}
}
```
A watch app that does this crashes in _dispatch_assert_queue_fail with comments about a block being run on the wrong queue. Swift 6 mode.
However, if I take the code in the closure and move it to a function
```swift
func responseHandler(response: [String: Any]) {
// process the response here
}
```
The app works as expected. Should I have expected this?